es
Feedback
LeetCode Weekly Solutions

LeetCode Weekly Solutions

Ir al canal en Telegram

Latest Jobs and Internships are regularly uploaded here : https://t.me/placementlelo If you want any other exam answers for free : @exam_cheating_bot Collaborations: @growth_admin

Mostrar más
7 053
Suscriptores
Sin datos24 horas
-67 días
-4430 días
Archivo de publicaciones
Out of Range Distinct Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9 #include <bits/stdc++.h> using namespace std; vector<vector<int>> tr; vector<int> ss; vector<int> nv; int n, m, cs; https://telegram.me/PLACEMENTLELO void d(int nd, int pt) { ss[nd] = 1; https://telegram.me/PLACEMENTLELO for (int nb : tr[nd]) { if (nb == pt) continue; d(nb, nd); ss[nd] += ss[nb]; } } https://telegram.me/PLACEMENTLELO int c(int nd) { int uf = 0; for (int nb : tr[nd]) { if (nd % nb == 0) uf++; uf += c(nb); } return uf; } Out of Range Distinct Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9

Count Subtree Factor Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9 #include <bits/stdc++.h> using namespace std; vector<vector<int>> tr; vector<int> sz; vector<int> pr; https://telegram.me/PLACEMENTLELO void f(int nd, int pa) { sz[nd] = 1; pr[nd] = pa; for (int ch : tr[nd]) { if (ch == pa) continue; f(ch, nd); sz[nd] += sz[ch]; } } https://telegram.me/PLACEMENTLELO int u(int nd) { int uc = 0; for (int v = 1; v <= sz[nd]; ++v) { if (nd % v == 0) { uc++; } } return uc; } https://telegram.me/PLACEMENTLELO int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, cl; cin >> n >> m >> cl; tr.resize(n + 1); sz.resize(n + 1); pr.resize(n + 1, -1); https://telegram.me/PLACEMENTLELO for (int i = 0; i < m; ++i) { int u1, u2; cin >> u1 >> u2; tr[u1].push_back(u2); tr[u2].push_back(u1); } https://telegram.me/PLACEMENTLELO f(1, -1); int tu = 0; for (int nd = 1; nd <= n; ++nd) { tu += u(nd); } https://telegram.me/PLACEMENTLELO cout << tu << endl; return 0; } Count Subtree Factor Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9

Intervals Maximization Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9 #include <bits/stdc++.h> using namespace std; int mb(vector<int>& A, vector<pair<int, int>>& it) { int placementlelo = A.size(); sort(it.begin(), it.end(), [](pair<int, int>& a, pair<int, int>& b) { return a.second < b.second; }); https://telegram.me/PLACEMENTLELO vector<int> dp(placementlelo + 1, 0); vector<int> ln(placementlelo + 1, 0); for (auto& p : it) { int st = p.first; int en = p.second; set<int> ds(A.begin() + st - 1, A.begin() + en); int bt = accumulate(ds.begin(), ds.end(), 0); int pe = ln[st - 1]; https://telegram.me/PLACEMENTLELO dp[en] = max(dp[en], dp[pe] + bt); for (int i = en; i <= placementlelo; i++) { ln[i] = max(ln[i], en); } } https://telegram.me/PLACEMENTLELO return *max_element(dp.begin(), dp.end()); } Intervals Maximization Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9

Path Queeries Code Infosys SP Exam Python https://telegram.me/+_hn3cBQVbGliYTI9 from collections import defaultdict, deque https://telegram.me/PLACEMENTLELO def dfs_count(node, parent, adj, A, mod_target): count = 0 stack = [(node, parent)] while stack: current, parent = stack.pop() if A[current] % 3 == mod_target: count += 1 for neighbor in adj[current]: if neighbor != parent: stack.append((neighbor, current)) return count https://telegram.me/PLACEMENTLELO def solve(N, M, A, E, Q, Queries): adj = defaultdict(list) for u, v in E: adj[u-1].append(v-1) adj[v-1].append(u-1) https://telegram.me/PLACEMENTLELO total_result = 0 for query in Queries: if query[0] == 1: placementlelo, U, X = query U -= 1 A[U] = X elif query[0] == 2: placementlelo, U, X = query U -= 1 mod_target = X % 3 count = dfs_count(U, -1, adj, A, mod_target) total_result += count Path Queeries Code Infosys SP Exam Python https://telegram.me/+_hn3cBQVbGliYTI9

Lost In Orange Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9 #include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int N, M; cin >> N >> M; https://telegram.me/PLACEMENTLELO vector<vector<int>> grid(N, vector<int>(M)); for (int i = 0; i < N; ++i){ for (int j = 0; j < M; ++j){ cin >> grid[i][j]; } } vector<vector<long long>> dp(N, vector<long long>(M, 0)); vector<vector<long long>> placementlelo(N, vector<long long>(M, LLONG_MAX)); if (grid[0][0] == 0) placementlelo[0][0] = 0; https://telegram.me/PLACEMENTLELO dp[0][0] = grid[0][0]; for (int i = 0; i < N; ++i){ for (int j = 0; j < M; ++j){ if (i == 0 && j == 0) continue; if (i > 0){ dp[i][j] = max(dp[i][j], dp[i - 1][j] + grid[i][j] - placementlelo[i - 1][j]); placementlelo[i][j] = min(placementlelo[i][j], placementlelo[i - 1][j] + 2); } if (j > 0){ dp[i][j] = max(dp[i][j], dp[i][j - 1] + grid[i][j] - placementlelo[i][j - 1]); placementlelo[i][j] = min(placementlelo[i][j], placementlelo[i][j - 1] + 2); } https://telegram.me/PLACEMENTLELO if (grid[i][j] == 0) placementlelo[i][j] = 0; } } https://telegram.me/PLACEMENTLELO cout << dp[N - 1][M - 1] << endl; return 0; } Lost In Orange Code Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9

RGB Counting Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9 const int MODULO = 1e9 + 7; int main() { int numElements, divisor; cin >> numElements >> divisor; vector<int> elements(numElements); for (int i = 0; i < numElements; i++) { cin >> elements[i]; } https://telegram.me/PLACEMENTLELO vector<vector<vector<long long>>> dp(divisor, vector<vector<long long>>(divisor, vector<long long>(divisor, 0))); dp[0][0][0] = 1; https://telegram.me/PLACEMENTLELO for (int value : elements) { vector<vector<vector<long long>>> newDp(divisor, vector<vector<long long>>(divisor, vector<long long>(divisor, 0))); for (int rSum = 0; rSum < divisor; rSum++) { for (int gSum = 0; gSum < divisor; gSum++) { for (int bSum = 0; bSum < divisor; bSum++) { if (dp[rSum][gSum][bSum] > 0) { newDp[(rSum + value) % divisor][gSum][bSum] = (newDp[(rSum + value) % divisor][gSum][bSum] + dp[rSum][gSum][bSum]) % MODULO; newDp[rSum][(gSum + value) % divisor][bSum] = (newDp[rSum][(gSum + value) % divisor][bSum] + dp[rSum][gSum][bSum]) % MODULO; newDp[rSum][gSum][(bSum + value) % divisor] = (newDp[rSum][gSum][(bSum + value) % divisor] + dp[rSum][gSum][bSum]) % MODULO; } } } } dp = newDp; } https://telegram.me/PLACEMENTLELO long long placementlelo = 0; for (int rSum = 0; rSum < divisor; rSum++) { for (int gSum = 0; gSum < divisor; gSum++) { int bSum = (divisor - rSum - gSum) % divisor; if (bSum < 0) bSum += divisor; placementlelo = (placementlelo + dp[rSum][gSum][bSum]) % MODULO; } } https://telegram.me/PLACEMENTLELO cout << placementlelo << endl; return 0; } RGB Counting Infosys SP Exam C++ https://telegram.me/+_hn3cBQVbGliYTI9

Guys follow us fast 👇🏻 https://instagram.com/placementlelo We will make our page private

Infosys SP Exam Answers will be uploaded here 👇 https://telegram.me/+_hn3cBQVbGliYTI9 Infosys Exam Discussion Group 👇 https://telegram.me/+oZ4x3k1RtXdkNWU1 Must Join both groups ✅ Share this with your friends who have Infosys exam on 4 August 😇

Infosys SP Exam Previous Year Paper with Answers 🔥

Infosys Exam Answers will be uploaded here 👇 https://telegram.me/+_hn3cBQVbGliYTI9 Infosys Exam Discussion Group 👇 https://telegram.me/+oZ4x3k1RtXdkNWU1 Must Join both groups ✅ Share this with your friends who have Infosys exam on 6th July 😇

Novago SDE Hiring 100% Correct Exam Answers Uploaded 👇 https://youtu.be/W5megr7i98k https://youtu.be/W5megr7i98k Same questions for ALL🚀 ✅ Share this video with all your friends and in college groups 🚀

Latest Off-Campus Jobs and Internships are Uploaded regularly here👇 1. https://telegram.me/PLACEMENTLELO 2. https://telegram.me/OFF_CAMPUS_JOBS_AND_INTERNSHIPS ✅ Must Join ✅

Send your questions in this groups 👇🏻 https://telegram.me/+8B154b769wk4ZjY9

Novago Exam Discussion Group 👇 https://telegram.me/+8B154b769wk4ZjY9

Novago SDE Hiring Challenge Answers will be uploaded here !