uk
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 день
Архів дописів
1st Question C++ LeetCode Weekly 416 https://telegram.me/+Q_kf6B6EFexiNmU9 class Solution { public:     bool reportSpam(vector<string>& message, vector<string>& bannedWords) {         unordered_set<string> bannedSet(bannedWords.begin(), bannedWords.end());         int count = 0;                  for (const string& word : message) {             if (bannedSet.find(word) != bannedSet.end()) {                 count++;                 if (count >= 2) {                     return true;                 }             }         }                  return false;     } }; 2 Python LeetCode Weekly 416 https://telegram.me/+Q_kf6B6EFexiNmU9 class Solution:     def minNumberOfSeconds(self, mountainHeight: int, workerTimes: List[int]) -> int:         def isPossible(maxTime, mountainHeight, workerTimes):             totalHeight = 0             for time in workerTimes:                 h = 0                 current_time = 0                 while current_time + (h + 1) * time <= maxTime:                     h += 1                     current_time += h * time                 totalHeight += h                                  if totalHeight >= mountainHeight:                     return True                          return totalHeight >= mountainHeight         low, high = 0, 1         while not isPossible(high, mountainHeight, workerTimes):             high *= 2                  while low < high:             mid = (low + high) // 2             if isPossible(mid, mountainHeight, workerTimes):                 high = mid             else:                 low = mid + 1         return low 3 Java LeetCode Weekly 416 https://telegram.me/+Q_kf6B6EFexiNmU9 #include <unordered_map> #include <string> class Solution { public:     long long validSubstringCount(std::string word1, std::string word2) {         int n = word1.size();         int m = word2.size();         if (m > n) return 0;         std::unordered_map<char, int> count2, count1;         for (char c : word2) {             count2[c]++;         }         long long result = 0;         int required = count2.size();         int formed = 0;         int left = 0;         for (int right = 0; right < n; ++right) {             char c = word1[right];             count1[c]++;             if (count2.count(c) && count1[c] == count2[c]) {                 formed++;             }             while (formed == required) {                 result += (n - right);                 char leftChar = word1[left];                 count1[leftChar]--;                 if (count2.count(leftChar) && count1[leftChar] < count2[leftChar]) {                     formed--;                 }                 left++;             }         }         return result;     } }; LeetCode Weekly 416 https://telegram.me/+Q_kf6B6EFexiNmU9

Goldman Sachs Aptitude Questions and Answers with Explanation 🔥 ✅ Share with your friends 😇

Juspay Exam Answers are uploaded here 👇 https://telegram.me/+_hn3cBQVbGliYTI9 Juspay Exam Discussion Group 👇 https://telegram.me/+8B154b769wk4ZjY9 Share with your friends 😇

All CodeChef codes for free ✅ Just comment on this reel which code you want and we will send it to your DM👇🏻 https://www.instagram.com/reel/DAD_DGsBdP9

Maximize Hamming Distance C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int test_cases; cin >> test_cases; while (test_cases--) { int num_rows, num_strings; cin >> num_rows >> num_strings; vector<pair<int, pair<int, int>>> data(num_rows); int result = 0; while (num_strings--) { string line; cin >> line; int zero_count = 0; int one_count = 0; int question_count = 0; for (int idx = 0; idx < line.size(); idx++) { if (line[idx] == '0') { data[idx].first++; } else if (line[idx] == '1') { data[idx].second.first++; } else { data[idx].second.second++; } } } for (int idx = 0; idx < num_rows; idx++) { int zeros = data[idx].first; int ones = data[idx].second.first; int questions = data[idx].second.second; while (questions--) { if (zeros <= ones) { zeros++; } else { ones++; } } result += (zeros * ones); } cout << result << endl; } return 0; } Maximize Hamming Distance C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Range Minimize C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { int t; cin>>t; while(t--) { int n; cin>>n; vector<int>vec(n); for(int i=0;i<n;i++) { cin>>vec[i]; } sort(vec.begin(),vec.end()); int ans1=vec[n-3]-vec[0]; int ans2=vec[n-1]-vec[2]; int ans3=vec[n-2]-vec[1]; cout<<min(ans1,min(ans2,ans3))<<endl; } return 0; } Range Minimize C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Winning World Finals C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include <iostream> using namespace std; int main() { // your code goes here int t; cin >> t; while(t--) { int m, p; cin >> m >> p; int ans = 0; @PLACEMENTLELO while(m < 299 && m+p+20*ans < 1000) { ++m; ++ans; } if(m+p+20*ans <= 1000) cout << ans << endl; else cout << ans-1 << endl; } return 0; } Winning World Finals C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Maximize Hamming Distance Java Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()); while (T-- > 0) { String[] nm = br.readLine().split(" "); int N = Integer.parseInt(nm[0]); int M = Integer.parseInt(nm[1]); char[][] strings = new char[M][N]; for (int i = 0; i < M; i++) { strings[i] = br.readLine().toCharArray(); } for (int i = 0; i < N; i++) { int count0 = 0; int count1 = 0; for (int j = 0; j < M; j++) { if (strings[j][i] == '0') count0++; else if (strings[j][i] == '1') count1++; } // Replace '?' optimally for (int j = 0; j < M; j++) { if (strings[j][i] == '?') { if (count0 >= count1) { strings[j][i] = '1'; count1++; } else { strings[j][i] = '0'; count0++; } } } } long totalHammingDistance = 0; for (int i = 0; i < M; i++) { for (int j = i + 1; j < M; j++) { totalHammingDistance += hammingDistance(strings[i], strings[j]); } } sb.append(totalHammingDistance).append("\n"); } System.out.print(sb.toString()); } private static int hammingDistance(char[] s1, char[] s2) { int distance = 0; for (int i = 0; i < s1.length; i++) { if (s1[i] != s2[i]) { distance++; } } return distance; } } Maximize Hamming Distance Java Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Maximize Hamming Distance C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include <bits/stdc++.h> using namespace std; #define int long long int32_t main() { int test_cases; cin >> test_cases; while (test_cases--) { int num_rows, num_strings; cin >> num_rows >> num_strings; vector<pair<int, pair<int, int>>> data(num_rows); int result = 0; while (num_strings--) { string line; cin >> line; int zero_count = 0; int one_count = 0; int question_count = 0; for (int idx = 0; idx < line.size(); idx++) { if (line[idx] == '0') { data[idx].first++; } else if (line[idx] == '1') { data[idx].second.first++; } else { data[idx].second.second++; } } } for (int idx = 0; idx < num_rows; idx++) { int zeros = data[idx].first; int ones = data[idx].second.first; int questions = data[idx].second.second; while (questions--) { if (zeros <= ones) { zeros++; } else { ones++; } } result += (zeros * ones); } cout << result << endl; } return 0; } Maximize Hamming Distance C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Range Minimize C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include<bits/stdc++.h> using namespace std; #define int long long int32_t main() { int t; cin>>t; while(t--) { int n; cin>>n; vector<int>vec(n); for(int i=0;i<n;i++) { cin>>vec[i]; } sort(vec.begin(),vec.end()); int ans1=vec[n-3]-vec[0]; int ans2=vec[n-1]-vec[2]; int ans3=vec[n-2]-vec[1]; cout<<min(ans1,min(ans2,ans3))<<endl; } return 0; } Range Minimize C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Winning World Finals C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 #include <iostream> using namespace std; int main() { // your code goes here int t; cin >> t; while(t--) { int m, p; cin >> m >> p; int ans = 0; @PLACEMENTLELO while(m < 299 && m+p+20*ans < 1000) { ++m; ++ans; } if(m+p+20*ans <= 1000) cout << ans << endl; else cout << ans-1 << endl; } return 0; } Winning World Finals C++ Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Maximize Hamming Distance Java Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9 import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int T = Integer.parseInt(br.readLine()); // Number of test cases while (T-- > 0) { String[] nm = br.readLine().split(" "); int N = Integer.parseInt(nm[0]); // Length of strings int M = Integer.parseInt(nm[1]); // Number of strings char[][] strings = new char[M][N]; for (int i = 0; i < M; i++) { strings[i] = br.readLine().toCharArray(); } for (int i = 0; i < N; i++) { int count0 = 0; int count1 = 0; for (int j = 0; j < M; j++) { if (strings[j][i] == '0') count0++; else if (strings[j][i] == '1') count1++; } // Replace '?' optimally for (int j = 0; j < M; j++) { if (strings[j][i] == '?') { if (count0 >= count1) { strings[j][i] = '1'; // Make strings more diverse count1++; } else { strings[j][i] = '0'; count0++; } } } } long totalHammingDistance = 0; for (int i = 0; i < M; i++) { for (int j = i + 1; j < M; j++) { totalHammingDistance += hammingDistance(strings[i], strings[j]); } } sb.append(totalHammingDistance).append("\n"); } System.out.print(sb.toString()); } private static int hammingDistance(char[] s1, char[] s2) { int distance = 0; for (int i = 0; i < s1.length; i++) { if (s1[i] != s2[i]) { distance++; } } return distance; } } Maximize Hamming Distance Java Codechef Starters 152 https://telegram.me/+Q_kf6B6EFexiNmU9

Cisco Hiring 2025 and 2026 grads👇🏻 https://telegram.me/PLACEMENTLELO/605

SAWiT Gen AI Challenge: Note: Only for Female Students Register Now: https://bit.ly/4dPUQzX You can easily get a job of 48 LPA by this. ✅ All female students will get Free Google Gemini Pro

Triangle Code C++ IBM https://telegram.me/+Q_kf6B6EFexiNmU9 double calculate_area(int a, int b, int c) { double p = (a + b + c) / 2.0; return (p * (p - a) * (p - b) * (p - c)); } int compare(const void* a, const void* b) { triangle* t1 = (triangle*)a; triangle* t2 = (triangle*)b; if (t1->area < t2->area) return -1; else if (t1->area > t2->area) return 1; else return 0; } int sort_by_area(triangle* tr, int n) { if (tr == NULL || n <= 0) { return -1; } for (int i = 0; i < n; i++) { tr[i].area = calculate_area(tr[i].a, tr[i].b, tr[i].c); } qsort(tr, n, sizeof(triangle), compare); return 0; } Triangle Code C++ IBM https://telegram.me/+Q_kf6B6EFexiNmU9

IPV6 Code Java IBM https://telegram.me/+Q_kf6B6EFexiNmU9 public static String convertToIpv6(String ipv4Address) { String[] octets = ipv4Address.split("\\."); if (octets.length != 4) { return "Invalid input"; } if (octets[0].equals("127")) { return "::1"; } StringBuilder ipv6 = new StringBuilder("::FFFF:"); try { for (int i = 0; i < 4; i++) { int octet = Integer.parseInt(octets[i]); if (octet < 0 || octet > 255) { return "Invalid input"; } String hex = String.format("%02X", octet); ipv6.append(hex); if (i == 1) { ipv6.append(":"); } } } catch (NumberFormatException e) { return "Invalid input"; } return ipv6.toString(); } IPV6 Code Java IBM https://telegram.me/+Q_kf6B6EFexiNmU9

Download the latest version of Telegram and get 100rs reward, reward is given every day ✅ Step 1: Register an account here 👉 Registration link: https://tatagroupmall.com/#/register?code=tata507 ✅ Step 2, when successfully registered send me TATA GAME account ID ✅ Contact to get reward Contact via Telegram: @Bella_tatamall Contact via Telegram: @Naila_Tata_Mall Contact via Telegram: @Anagha_2020