fa
Feedback
LeetCode Weekly Solutions

LeetCode Weekly Solutions

رفتن به کانال در 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

نمایش بیشتر
7 053
مشترکین
اطلاعاتی وجود ندارد24 ساعت
-67 روز
-4430 روز
آرشیو پست ها
TCS Mass Hiring: TCS is Hiring for the role of Ninja and Digital. Graduation Year: 2025 Salary: Ninja - 3.36 LPA Digital - 7 LPA Location: Across India Apply Link: https://www.instagram.com/reel/DENDfItSqSy Telegram: https://telegram.me/PLACEMENTLELO Registration Deadline: 23rd January 2025

Nation With NaMo - Government of India Mega Hiring: Graduation Year: 2025 / 2026 / 2027 / 2028 Eligibility: 1st, 2nd, 3rd and 4th year College Students can apply in this 🤩 Placement and internship Offers for selected students at Nation With NaMo. 💸 Prizes worth ₹18 Lakhs and macbook are up for grabs. Apply Link: https://www.instagram.com/reel/DDwpWEMSpxb Must Apply ✅

Infosys SP Exam Answers will be uploaded here 👇🏻 https://telegram.me/+Xqpv6kw1D5k4OTI1 Infosys Exam Discussion Group 👇🏻 https://telegram.me/+njYA5MfMVcs5OTRlMust join both the groups ! Share these groups with your friends 😇

Infosys Mass Hiring Internship: Graduation Year: 2024 / 2025 / 2026 / 2027 Stipend: 25k to 50k per month Apply Link: https://www.instagram.com/reel/DDURPp5yoBt

TCS CodeVita All 100% Correct Answers uploaded 👇🏻 https://youtu.be/3r4pYCrpXe8 https://youtu.be/3r4pYCrpXe8 Share this with your friends 😇

Now, All 100% Correct TCS CodeVita Codes will be posted on both of these channels 👇🏻 1. https://telegram.me/PLACEMENTLELO 2. https://telegram.me/OFF_CAMPUS_JOBS_AND_INTERNSHIPS Must Join both groups ✅

Buzz Sale C++ TCS CodeVita Zone 2 https://telegram.me/+_hn3cBQVbGliYTI9 #include <iostream> #include <vector> #include <unordered_map> using namespace std; https://telegram.me/PLACEMENTLELO int main() { int n; cin >> n; // @PLACEMENTLELO vector<int> ids(n), costs(n); for (int i = 0; i < n; i++) cin >> ids[i]; for (int i = 0; i < n; i++) cin >> costs[i]; int budget; cin >> budget; // @PLACEMENTLELO int mfi = 0, mfw = 0; for (int i = 0; i < n; i++) { int buyCost = costs[i]; int maxQty = budget / buyCost; // @PLACEMENTLELO if (maxQty > 0) { int cfi = 0; int cfw = 0; https://telegram.me/PLACEMENTLELO for (int j = 0; j < n; j++) { if (i != j && ids[i] % ids[j] == 0) { cfi += maxQty; cfw += costs[j] * maxQty; } } // @PLACEMENTLELO if (cfi > mfi || (cfi == mfi && cfw > mfw)) { mfi = cfi; mfw = cfw; } } } // @PLACEMENTLELO cout << mfi << " " << mfw << endl; return 0; } Buzz Sale C++ TCS CodeVita Zone 2 https://telegram.me/+_hn3cBQVbGliYTI9

Desert Queen C++ TCS CodeVita Zone 2 https://telegram.me/+_hn3cBQVbGliYTI9 #include <bits/stdc++.h> using namespace std; int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; bool isValid(int x, int y, int n, const vector<vector<char>>& grid) { return x >= 0 && x < n && y >= 0 && y < n && grid[x][y] != 'M'; } // @PLACEMENTLELO int fMW(int n, const vector<vector<char>>& grid, pair<int, int> start, pair<int, int> end) { vector<vector<int>> placementlelo(n, vector<int>(n, INT_MAX)); queue<pair<int, int>> q; https://telegram.me/+_hn3cBQVbGliYTI9 q.push(start); placementlelo[start.first][start.second] = 0; while (!q.empty()) { auto [x, y] = q.front(); q.pop(); https://telegram.me/+_hn3cBQVbGliYTI9 for (int d = 0; d < 4; d++) { int nx = x + dir[d][0]; int ny = y + dir[d][1]; if (isValid(nx, ny, n, grid)) { int cost = (grid[x][y] == 'T' && grid[nx][ny] == 'T') ? 0 : 1; if (placementlelo[x][y] + cost < placementlelo[nx][ny]) { placementlelo[nx][ny] = placementlelo[x][y] + cost; q.push({nx, ny}); } } } } https://telegram.me/+_hn3cBQVbGliYTI9 return placementlelo[end.first][end.second]; } @PLACEMENTLELO int main() { int n; cin >> n; https://telegram.me/PLACEMENTLELO vector<vector<char>> grid(n, vector<char>(n)); pair<int, int> start, end; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> grid[i][j]; if (grid[i][j] == 'S') start = {i, j}; if (grid[i][j] == 'E') end = {i, j}; } } int result = fMW(n, grid, start, end); cout << result << endl; return 0; } Desert Queen C++ TCS CodeVita Zone 2 https://telegram.me/+_hn3cBQVbGliYTI9

String Obsession C++ TCS CodeVita Zone 2 100% Correct Code ✅ https://telegram.me/+_hn3cBQVbGliYTI9 #include <iostream> #include <string> #include <vector> #include <unordered_map> https://telegram.me/+_hn3cBQVbGliYTI9 using namespace std; int dp(string& s, vector<string>& v, unordered_map<string, int>& memo) { if (memo.count(s)) return memo[s]; // @PLACEMENTLELO int placementlelo = 0; https://telegram.me/+_hn3cBQVbGliYTI9 for (auto& x : v) { size_t pos = s.find(x); // @PLACEMENTLELO if (pos != string::npos) { string new_string = s.substr(0, pos) + s.substr(pos + x.size()); placementlelo = max(placementlelo, 1 + dp(new_string, v, memo)); } } // @PLACEMENTLELO return memo[s] = placementlelo; } int main() { int n; cin >> n; // @PLACEMENTLELO vector<string> substrings(n); for (int i = 0; i < n; ++i) { cin >> substrings[i]; } https://telegram.me/+_hn3cBQVbGliYTI9 string mainString; cin >> mainString; // @PLACEMENTLELO unordered_map<string, int> memo; cout << dp(mainString, substrings, memo); return 0; } https://telegram.me/+_hn3cBQVbGliYTI9 String Obsession C++ TCS CodeVita Zone 2 100% Correct Code ✅ https://telegram.me/PLACEMENTLELO

TCS CodeVita Round 1 Zone 2: TCS CodeVita Exam Answers will be uploaded here 👇🏻 https://telegram.me/+_hn3cBQVbGliYTI9 TCS CodeVita Discussion Group 👇🏻 https://telegram.me/+oZ4x3k1RtXdkNWU1Must join both the groups ! Share these groups with your friends and help them get a job 😇

TCS CodeVita All 100% Correct Answers uploaded 👇🏻 https://youtu.be/a9wgj8hm20g https://youtu.be/a9wgj8hm20g Share this with your friends 😇

TCS CodeVita Exam Answers will be uploaded here 👇🏻 https://telegram.me/+_hn3cBQVbGliYTI9 TCS CodeVita Discussion Group 👇🏻 https://telegram.me/+oZ4x3k1RtXdkNWU1Must join both the groups ! Share these groups with your friends and help them get a job 😇

TCS CodeVita Exam Answers Group👇🏻 https://www.linkedin.com/posts/placementlelo_tcs-tcscodevita-career-activity-7262117016117886976-be3X Share this with your friends 😇

LeetCode Biweekly 143 - A, B, C, D for Free 👇🏻 https://www.placementlelo.in/LeetCode-Solutions Just Register on this to see the codes

LeetCode Biweekly 143 - A, B, C, D for Free 👇🏻 https://www.placementlelo.in/LeetCode-Solutions Just Register on this to see the codes

CodeChef all 100% Correct Codes Uploaded 👇🏻 https://www.placementlelo.in/exam/codechef-starters-157-solutions/ We will keep on updating answers to all questions on the website, so check in every 15 minutes.

Leetcode Weekly 419 C Python https://telegram.me/+Q_kf6B6EFexiNmU9 MOD = 10**9 + 7 class Solution: def countWinningSequences(self, s: str) -> int: n = len(s) win_against = {'F': 'W', 'W': 'E', 'E': 'F'} memo = {} def dp(i, last_bob_move, score_diff): if i == n: return 1 if score_diff > 0 else 0 if (i, last_bob_move, score_diff) in memo: return memo[(i, last_bob_move, score_diff)] total_ways = 0 alice_move = s[i] for bob_move in 'FWE': if bob_move == last_bob_move: continue new_score_diff = score_diff if bob_move == win_against[alice_move]: new_score_diff += 1 elif win_against[bob_move] == alice_move: new_score_diff -= 1 total_ways = (total_ways + dp(i + 1, bob_move, new_score_diff)) % MOD memo[(i, last_bob_move, score_diff)] = total_ways return total_ways return dp(0, None, 0) Leetcode Weekly 419 C Python https://telegram.me/+Q_kf6B6EFexiNmU9

Leetcode Weekly 419 B C++ https://telegram.me/+_hn3cBQVbGliYTI9 class Solution { public: pair<bool, int> checkPerfect(TreeNode* node) { if (!node) return {true, 0}; auto leftResult = checkPerfect(node->left); auto rightResult = checkPerfect(node->right); if (leftResult.first && rightResult.first && leftResult.second == rightResult.second) { return {true, leftResult.second + rightResult.second + 1}; } return {false, 0}; } void gatherPerfectSizes(TreeNode* node, vector<int>& subtreeSizes) { if (!node) return; auto result = checkPerfect(node); if (result.first) { subtreeSizes.push_back(result.second); } gatherPerfectSizes(node->left, subtreeSizes); gatherPerfectSizes(node->right, subtreeSizes); } int kthLargestPerfectSubtree(TreeNode* root, int k) { vector<int> subtreeSizes; gatherPerfectSizes(root, subtreeSizes); if (subtreeSizes.empty()) return -1; sort(subtreeSizes.rbegin(), subtreeSizes.rend()); return (k <= subtreeSizes.size()) ? subtreeSizes[k - 1] : -1; } }; Leetcode Weekly 419 B C++ https://telegram.me/+_hn3cBQVbGliYTI9

Leetcode Weekly 419 A C++ https://telegram.me/+_hn3cBQVbGliYTI9 #include <vector> #include <unordered_map> #include <algorithm> using namespace std; class Solution { public: vector<int> findXSum(vector<int>& nums, int k, int x) { int n = nums.size(); vector<int> answer; for (int i = 0; i <= n - k; ++i) { unordered_map<int, int> frequency; for (int j = i; j < i + k; ++j) { frequency[nums[j]]++; } vector<pair<int, int>> freqList; for (const auto& entry : frequency) { freqList.push_back({entry.second, entry.first}); } sort(freqList.begin(), freqList.end(), [](const pair<int, int>& a, const pair<int, int>& b) { if (a.first != b.first) return a.first > b.first; return a.second > b.second; }); int sum = 0; int count = 0; for (const auto& entry : freqList) { int frequency = entry.first; int value = entry.second; if (count >= x) break; sum += frequency * value; count++; } answer.push_back(sum); } return answer; } }; Leetcode Weekly 419 A C++ https://telegram.me/+_hn3cBQVbGliYTI9

Bulk hiring is open for these 4 companies: 1. Capgemini 2. Accenture 3. Reliance 4. TCS Last Date to Apply: 6 October We have uploaded all the details in the LinkedIn post. Post Link: https://bit.ly/mass_hiring ✅ Make sure to apply to all 4 opportunities. Share this with your friends 😇