From 36c1ad8ffa16345096c19c08ed8879ebb645e625 Mon Sep 17 00:00:00 2001 From: Sudo-Aditi <96663557+Sudo-Aditi@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:24:41 +0530 Subject: [PATCH] Create Count the number of fair prices --- Count the number of fair prices | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Count the number of fair prices diff --git a/Count the number of fair prices b/Count the number of fair prices new file mode 100644 index 00000000..880b1d18 --- /dev/null +++ b/Count the number of fair prices @@ -0,0 +1,18 @@ +A VERY NICE implementation of BINARY SEARCH TO BE LEARNT HERE + +class Solution { +public: + long long countFairPairs(vector& nums, int lower, int upper) { + long long int ans = 0; + sort(nums.begin(),nums.end()); + for(int i=0;i