This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ program for the above approach | |
#include <bits/stdc++.h> | |
using namespace std; | |
int countTriplets(int arr[], int N) | |
{ | |
// Sort the array | |
sort(arr, arr + N); | |
// Stores count of triplets | |
int l, r, i, j, ans = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ program for the above approach | |
#include <bits/stdc++.h> | |
using namespace std; | |
// Function to find the Kth element in a | |
// sorted and rotated array at random point | |
int findkthElement(vector<int> arr, int n, int K) | |
{ | |
// Set the boundaries for binary search |