Leetcode Weekly Contest 404 || Part 1

preview_player
Показать описание

Video solution on 3rd problem: Same approach as discussed in this video

Рекомендации по теме
Комментарии
Автор

Thank you bhai. I was so close in solving the first question, I was back in giving two function calls(didnt think that) and also for rows.. anyway thank you so much!!

TalhaTabrez
Автор

first solution is too good man !! thank you please do make these videos for further contests too. :)

FinEduTalks
Автор

Bhai yaar m 550 question solve kar chuka hu par phir bhi mujse contest m 3rd wala question solve nhi hota kuch batao ki kaise improve karu problem solving ko

akshanshsharma
Автор

bhai thank you so much your soloution is osm bro

codecreateriitp
Автор

thx a lot for such a nice explanation of every question

shikharpandya
Автор

what is issue in this code not covering all testcases, same as ur code and approach
for qus 2

class Solution {
public:
int findoddsub(vector<int> &arr){
int n = arr.size();
int i = 0;
int count_oddeven = 0;
int count_evenodd = 0;

// Count transitions starting with odd first
int f = 1;
while(i < n) {
while(i < n && arr[i] == 0) i++;
if (i < n && arr[i] % 2 == f) {
count_oddeven++;
f = 1 - f;
}
i++;
}

// Reset i and count transitions starting with even first
i = 0;
f = 0;
while(i < n) {
while(i < n && arr[i] != 0) i++;
if (i < n && arr[i] % 2 == f) {
count_evenodd++;
f = 1 - f;
}
i++;
}

return max(count_oddeven, count_evenodd);
}

int findevensub(vector<int>& arr){
int n = arr.size();
int count_even = 0;
for(int i = 0; i < n; i++){
if(arr[i] % 2 == 0){
count_even++;
}
}
return max(count_even, (n - count_even));
}

int maximumLength(vector<int>& arr) {
int even = findevensub(arr);
int odd = findoddsub(arr);
return max(even, odd);
}
};

studywarriors-ih
Автор

third question ke video pura dhan se deka and last mai c*** kat gaya

tusharnanda
join shbcf.ru