LeetCode Weekly Solutions
7.29K subscribers
34 photos
11 files
101 links
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
Download Telegram
Cisco Hiring 2025 and 2026 grads👇🏻
https://telegram.me/PLACEMENTLELO/605
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
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
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
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
Juspay Exam Answers are uploaded here 👇
https://telegram.me/+_hn3cBQVbGliYTI9

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

Share with your friends 😇
Goldman Sachs Aptitude QuestionsAnswers with Explanation (2).pdf
3.1 MB
Goldman Sachs Aptitude Questions and Answers with Explanation 🔥

Share with your friends 😇
Goldman Sachs 22nd September Exam:

Goldman Sachs Exam Answers will be uploaded here 👇🏻
https://telegram.me/+_hn3cBQVbGliYTI9

Goldman Sachs Discussion Group 👇🏻
https://telegram.me/+njYA5MfMVcs5OTRl

Share with your friends and juniors of 2026 batch 😇
Question -
A fighter pilot observes a boy on the ground at an angle of depression of 45°. After flying for some time, the angle of depression changed to 60°. If the fighter plane is flying at a height of 300 m, then find the time (in seconds) for which the fighter plane flew between the two instances of observation. (Speed of fighter plane = 360 km/hr)

Pick ONE option
2 - √3
3 -√3
2
None of these


Answer: 3 - √3

https://telegram.me/+_hn3cBQVbGliYTI9
Guys, most of the questions are same for everyone as there is a pool of questions.
They are just in random order.