LeetCode Weekly Solutions


Гео и язык канала: не указан, не указан
Категория: не указана


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

Связанные каналы  |  Похожие каналы

Гео и язык канала
не указан, не указан
Категория
не указана
Статистика
Фильтр публикаций


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/+njYA5MfMVcs5OTRl

Must 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 😇


Репост из: TCS HackQuest Season 9 Solutions
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 ✅


Репост из: TCS HackQuest Season 9 Solutions
Buzz Sale
C++

TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9

#include
#include
#include

using namespace std;
https://telegram.me/PLACEMENTLELO

int main() {
int n;
cin >> n;
// @PLACEMENTLELO
vector 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


Репост из: TCS HackQuest Season 9 Solutions
Desert Queen
C++

TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9

#include
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& grid) {
return x >= 0 && x < n && y >= 0 && y < n && grid[x][y] != 'M';
}
// @PLACEMENTLELO
int fMW(int n, const vector& grid, pair start, pair end) {
vector placementlelo(n, vector(n, INT_MAX));
queue 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 grid(n, vector(n));
pair 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


Репост из: TCS HackQuest Season 9 Solutions
String Obsession
C++

TCS CodeVita Zone 2
100% Correct Code ✅

https://telegram.me/+_hn3cBQVbGliYTI9

#include
#include
#include
#include
https://telegram.me/+_hn3cBQVbGliYTI9

using namespace std;

int dp(string& s, vector& v, unordered_map& 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 substrings(n);
for (int i = 0; i < n; ++i) {
cin >> substrings[i];
}
https://telegram.me/+_hn3cBQVbGliYTI9

string mainString;
cin >> mainString;
// @PLACEMENTLELO
unordered_map memo;

cout


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/+oZ4x3k1RtXdkNWU1

Must 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/+oZ4x3k1RtXdkNWU1

Must 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 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 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& 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 subtreeSizes;
gatherPerfectSizes(root, subtreeSizes);

if (subtreeSizes.empty()) return -1;

sort(subtreeSizes.rbegin(), subtreeSizes.rend());

return (k


Leetcode Weekly 419
A
C++

https://telegram.me/+_hn3cBQVbGliYTI9

#include
#include
#include

using namespace std;

class Solution {
public:
vector findXSum(vector& nums, int k, int x) {
int n = nums.size();
vector answer;

for (int i = 0; i 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 😇


Репост из: Placement Lelo 2.0
Google Hiring Software Engineer:

Graduation Year: 2024 / 2023

Salary: 35 to 40 LPA
Location: Bengaluru / Gurgaon / Hyderabad / Mumbai / Pune

Apply Link: https://tinyurl.com/55ehdkdj

Telegram: https://telegram.me/OFF_CAMPUS_JOBS_AND_INTERNSHIPS


Cognizant
Database Query Question

https://telegram.me/+Q_kf6B6EFexiNmU9

SELECT instructor.first_name AS "First Name", instructor.last_name AS "Last Name"
FROM instructor
WHERE instructor.type = 'full-time'
  AND instructor.last_name LIKE 'C%';

Cognizant
Database Query Question

https://telegram.me/PLACEMENTLELO


Cognizant
Database Query Question

https://telegram.me/+Q_kf6B6EFexiNmU9


Cognizant Exam Answers will be uploaded here 👇🏻
https://telegram.me/+Q_kf6B6EFexiNmU9

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

Share this with your friends 😇

Показано 20 последних публикаций.