Codeforces|Leetcode|Codechef free solutions
الذهاب إلى القناة على Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
إظهار المزيد4 317
المشتركون
لا توجد بيانات24 ساعات
-137 أيام
-5230 أيام
أرشيف المشاركات
Tomorrow 1 Accenture oa slot available
Microsoft oa slots available
Dm @Cpsoln to book your oa slots🔥🔥🔥
Repost from Codeforces|Leetcode|Codechef free solutions
We just help one people at one time in coding rounds means we doesn't distribute solutions to anyone.
So there will be no chance of plagiarism. That's why we always ask to you book slot one day prior.
For example: if you have an oa of Microsoft at 4 pm then we will not accept other person oa means we will available for you only.
But if someone book the slot prior then you then we can't do anything It basically queue (FIFO😁).
So, Dm @Cpsoln to book your slots
Repost from Codeforces|Leetcode|Codechef free solutions
Hello guys
📌📌📌📌📌📌📌📌📌📌📌
Important thing you should note:
If you really want to get shortlisted for interviews(means Cracking coding rounds) then don't just copy from the channels who are giving free codes because many are copying the same code and even if you change the variables, add comments this will not work because they are billion dollar companies so you will definitely get plagiarism.
Also don't buy solutions from them who are selling the same code to everyone because in this case you are just wasting your money and not qualifying your oa too.
So, I will only suggest you to don't loose this opportunity otherwise it's your choice. If you are not believing me then wait watch and see.
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <climits>
using namespace std;
vector<vector<long long>> sparse;
long long query(int s, int e) {
int diff = e - s + 1;
int k = log2(diff);
return max(sparse[s][k], sparse[e - (1 << k) + 1][k]);
}
long long ans(vector<vector<long long>>& m, int n) {
for (int i = 0; i < n; i++) {
sparse[i][0] = m[i][1];
}
for (int i = 1; i < 18; i++) {
for (int j = 0; j + (1 << i) <= n; j++) {
sparse[j][i] = max(sparse[j][i - 1], sparse[j + (1 << (i - 1))][i - 1]);
}
}
set<long long> s;
long long minVal = LLONG_MAX;
for (int i = 0; i < n; i++) {
long long maxVal = 0;
if (i != n - 1) {
maxVal = query(i + 1, n - 1);
minVal = min(minVal, abs(m[i][0] - maxVal));
}
if (i != 0) {
auto it = s.lower_bound(m[i][0]);
if (it != s.begin() && *prev(it) > maxVal) {
minVal = min(minVal, abs(m[i][0] - *prev(it)));
}
if (it != s.end() && *it > maxVal) {
minVal = min(minVal, abs(m[i][0] - *it));
}
if (m[i - 1][0] > maxVal) {
minVal = min(minVal, abs(m[i][0] - m[i - 1][0]));
}
}
s.insert(m[i][1]);
}
return minVal;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<vector<long long>> m(n, vector<long long>(2));
sparse.assign(n, vector<long long>(18));
vector<long long> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> m[i][0];
a[i] = m[i][0];
cin >> m[i][1];
b[i] = m[i][1];
}
sort(m.begin(), m.end(), [](const vector<long long>& u, const vector<long long>& v) {
return (u[0] == v[0]) ? u[1] < v[1] : u[0] < v[0];
});
long long aa = ans(m, n);
for (int i = 0; i < n; i++) {
m[i][0] = b[i];
m[i][1] = a[i];
}
sort(m.begin(), m.end(), [](const vector<long long>& u, const vector<long long>& v) {
return (u[0] == v[0]) ? u[1] < v[1] : u[0] < v[0];
});
long long ab = ans(m, n);
cout << min(aa, ab) << endl;
}
return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define int long long
typedef pair<int, int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define PB push_back
#define F first
#define S second
#define ALL(a) a.begin(), a.end()
#define SET(a, b) memset(a, b, sizeof(a))
#define SZ(a) (int)(a.size())
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define fast_io \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define deb(a) cerr << #a << " = " << (a) << endl;
#define deb1(a) \
cerr << #a << " = [ "; \
for (auto it = a.begin(); it != a.end(); it++) cerr << *it << " "; \
cerr << "]\n";
#define endl "\n"
const long long mod = 1e9 + 7;
int change_mod(int curr, int req) {
int m1 = curr % 3;
int m2 = req % 3;
if (m1 == m2)
return 0;
if (m1 < m2)
return m2 - m1;
return m2 + (3 - m1);
}
int solver(vector<int> a) {
int ans = 0;
for (int i = 3; i < a.size(); i++) {
ans += change_mod(a[i], a[i - 3]);
a[i] = a[i - 3];
}
return ans;
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
FOR(i, 0, n) {
cin >> a.at(i);
}
VVI X;
FOR(i, 0, 3) {
FOR(j, 0, 3) {
FOR(k, 0, 3) {
if (((i + j + k) % 3) == 0)
X.push_back({i, j, k});
}
}
}
int ans = 1e9;
for (auto vec : X) {
VI temp = vec;
for (auto x : a) temp.PB(x);
ans = min(ans, solver(temp));
}
cout << ans << endl;
}
signed main() {
fast_io;
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int totalTests = 1;
cin >> totalTests;
for (int testNo = 1; testNo <= totalTests; testNo++) {
// cout << "Case #" << testNo << ": ";
solve();
}
return 0;
}
Today codechef solutions are for free
Dm @Cpsoln
Codechef Div 2 A B done
Codechef solutions will be available for free
Dm @Cpsoln for free code
Sprinklr and Microsoft solutions available
Dm @Cpsoln
