MORGAN STANLEY OA Help : Interview Help
Ir al canal en Telegram
Codeforces Codechef Leetcode AtCoder GFG CodeStudio All Contests Solutions available.
Mostrar más894
Suscriptores
-124 horas
-27 días
-530 días
Archivo de publicaciones
100094. Subarrays Distinct Element Sum of Squares I
Done ✅
Dm @cp_wala
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("popcnt")
#define int long long
#define tccc \
int t; \
cin >> t; \
while (t--)
void DUPLET()
{
int n;
cin >> n;
if (n % 2 == 0)
cout << n << ' ' << n + 1 << endl;
else
cout << n << ' ' << n - 1 << endl;
}
signed main()
{
tccc
DUPLET();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tc \
int tcc; \
cin >> tcc; \
while (tcc--)
void CHEAT()
{
int n;
cin >> n;
cout << n / 7 + (n % 7 > 1) << endl;
}
signed main()
{
tc
CHEAT();
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans=1;
for(int i=0;i<n;i++){
if(!i) {if(a[i]==ans) ans++; continue;}
ans++;
if(a[i]==ans) ans++;
}
cout<<ans<<endl;
}
}
// A
Kth Index
GCD Sum
Palindrome World
Ninja and Biryani Party
These questions done ✅
int n, x;
bool func(int middle_ele, vi &arr)
{
int req = 0;
for (int i = 0; i < n; i++)
{
if (middle_ele < arr[i])
continue;
req += middle_ele - arr[i];
}
return req <= x;
}
void e()
{
cin >> n >> x;
takeInputArr;
int l = 0, h = 1e13, middle_ele;
while (h - l > 1)
{
middle_ele = (h + l) / 2;
if (func(middle_ele, arr))
l = middle_ele;
else
h = middle_ele - 1;
}
if (func(h, arr))
cout << h << '\n';
else
cout << l << '\n';
}
// E
