OA Help : Interview Help
Відкрити в Telegram
Codeforces Codechef Leetcode AtCoder GFG CodeStudio All Contests Solutions available.
Показати більше898
Підписники
Немає даних24 години
-47 днів
-1430 день
Архів дописів
https://leetcode.com/Virus_ARzk/
https://leetcode.com/rohitashwa01/
Anyone wants these IDs?
Very cheap price, dm me ☠️
if anyone wants to buy this Codeforces id, dm me @cp_wala
https://codeforces.com/profile/Loki_Coder
if anyone wants to buy this Codeforces id, dm me @cp_wala
https://codeforces.com/profile/Loki_Coder
Bhai koi AtCoder de raha hai to please Q2 ka testcase explain kardo 🥺
@cp_wala
void code()
{
int n;
cin >> n;
vector arr(n);
for (int &i : arr)
cin >> i;
int minIndex = 0;
for (int i = 0; i < n; i++)
if (arr[i] < arr[minIndex])
minIndex = i;
int res = minIndex;
for (int i = minIndex; i < n - 1; i++)
if (arr[i] > arr[i + 1])
res = -1;
cout << res << endl;
}
// E
// Enjoy ❤️
E solution
Find the smallest element index and if the array is sorted from there then print its index otherwise if not sorted print -1
void solve()
{
int n;
cin >> n;
vi arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i];
map freq;
for (int i = 0; i < n; i++)
freq[arr[i]]++;
int res = 0;
for (auto e : freq)
res += e.second * (e.second - 1) / 2;
res += freq[1] * freq[2];
cout << res << endl;
}
// D
// Here it is, enjoy❤️😁
D is also easy, just count the frequency of each element
Then add nC2 for every n belongs to frequency
and there is special case that 2^4 = 4^2 so just add the product of freq of 2 and freq of 4 😁❤️
B is brute force
Check for every factor of n
calculate max min for each one and find the max difference between them
