Code with Cisco OA Help : Interview Help
Open in Telegram
Codeforces Codechef Leetcode AtCoder GFG CodeStudio All Contests Solutions available.
Show more916
Subscribers
No data24 hours
-47 days
+5530 days
Posts Archive
class Solution
{
int bits[1001];
void init()
{
bits[0] = 0;
for (int idx = 1; idx < 1001; idx++)
bits[idx] = (idx & 1) + bits[idx / 2];
}
public:
int sumIndicesWithKSetBits(vector &arr, int k)
{
init();
int sm = 0;
for (int idx = 0; idx < arr.size(); idx++)
if (bits[idx] == k)
sm += arr[idx];
return sm;
}
};
// A
S100
#include <iostream>
#include <string>
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
int N;
cin >> N;
string s;
cin >> s;
bool flag = false;
for (int i = 0; i < N; ++i)
if (s[i] == '0' || flag)
s[i] = '0';
else if (i == N - 2)
break;
else
s[i] = '1', flag = true;
cout << s << endl;
}
}
void CHOCOCHEF()
{
int n;
cin >> n;
cout << "1 1 " << n - 2 << endl;
}
void SURPLUS()
{
int a1, a2, b1, b2;
cin >> a1 >> a2 >> b1 >> b2;
int ans = a2 + b2 - b1 - a1;
if (ans > 0)
yes;
else
no;
}
#include <iostream>
#include <set>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
set<int> s;
for (int i = 0; i < n; i++)
{
int num;
cin >> num;
s.insert(num);
}
int mex = 0;
set<int> mis;
for (int i = 0; i <= n + 1; i++)
{
if (s.find(i) == s.end())
{
mis.insert(i);
}
}
bool f = true;
int c = 0;
while (c < 2 * n + 1 && f)
{
int v = *mis.begin();
cout << *mis.begin() << endl;
mis.erase(mis.begin());
cout.flush();
int y;
cin >> y;
if (y == -1)
{
f = false;
}
else
{
s.erase(y);
mis.insert(y);
}
c += 1;
}
}
return 0;
}
For the complete interview preparation course of GFG, dm me
@cp_wala
Available now! Telegram Research 2025 — the year's key insights 
