today after learning from YOUR STL series I tried to solve this questions using MAP and I was able to solve this question with help of maps and hashing even in lesser time...YOUR SOLUTION took on Average of more than 1 seconds but with help of MAP it took less than 0.5 on every test case...YOU ARE LIKE A BOON FOR ME...THANKS BROTHER..
@@komaldeepsingh6356 hey i too solved it using maps ... #include using namespace std; int main() { int T; cin >> T; while(T--) { int n,q; cin >> n >> q; string s ; cin >> s; unordered_map < char ,vector< int >> m; for(int i=0;i
hey, did you learnt all these optimization approaches by hit n trial? if not can you share the resources by which we can learn these optimizations? btw very nice content, keep it up.
Your this mentality is completely wrong, he's an alumni of IIIT Allahabad, how will he be able to explain how he learnt these techniques, this is completely unacceptable comment @@kartikforwork
where did iita dome bw? can you explain ur point more accurately. its a normal think to ask people how they learn it. why can't he explain it?@@shishirsaraf8498
We can be do in this way "Pre-calculate the How many letters have odd count from 0 to i. And after apply prefix sum can be found no. of odd count letter.(b/w L-R). if(no
it would be less confusing if the array was declared arr[26][N] like you discussed! Btw great playlist. Hoping to finish it soon and be better at CP. :)
Bhaiya ,mene kai saare articles/videos dekhi, but aap jesa STL kisi ne nai samjhaaya, aapka videos superrllyyyy best and unique hai bilkul, and mein ye sach me keh raha kyuki me jaanta hu mein kitna pareshan tha apne doubts ko le kar, merey saare doubts aapne clear kar li hai,,,Vesey aap aur jaada likes and subscribers deserve kartey ho🙏🏻🙏🏻🙏🏻
Thank you , sir. Here is the code if anyone needs it. #include using namespace std; const int N=1e5+10; int hsh[N][26]; int main() { int t;int n; int q; cin>>t ; while(t--) { cin>>n ;cin>>q ; for (int i=0;is ; for (int i=0;i>r ; int oddcount=0; //The concept is that if oddcount
nay nay LUV-San finally some question which make me more exited then rest bcoz of One Piece Dressrosa Arc I am watching atleast one video of yours everyday. Arigato Gozaimus. If you are reading this comment then plzz mention your fav. Arc
If odd_count == 1 or 0 then it will print "YES" but how it is justified for the EVEN length sub-string to have odd_count == 1 ? If odd_count == 1 for an even length substring from L to R ..... it wont form palindrome.
you can use any just with slight change in code. its very similar. how i think is int a[n] is one array, so int a[n][26] are 26 arrays it just an imagination pov
According to your explanation ie. for each letter one 'n' sized array, the hsh array should be hsh[26][N]. means, 26 rows and N columns and accordingly there'll be few changes(swaps) in the code. But anyways your code is working fine. Please correct me anyone, if I am wrong. and Thanks luv bhai.. for these explanations... for your dedicated teaching... I am sure, I'll be a good coder one day thanks to you.❤❤
its just a matter of imagination i imagine, int hash[N] array of N integers and adding 26 once more to infront makes 26 arrays of those, what you are thinking is also correct only.
@@iamluvso..a matter of convention ! Anyways, you have already made my 2d array concept crystal clear. So thanks for giving me the opportunity to again analyse n-D array in a meaningful way. 🙏🏻🙏🏻❤️
N size ke 26 arrays means [N][26] , int a[n] is one array if want to make 5 such array then its like int a[n][5], putting bracket in front of anything make it an array. so existing int a[N] and then 26 arrays of that int a[N][26], but i get it why you are confused, but as i said its same thing only..
@@iamluv Yes... you are right bhaiyya,actually ham log ko aadat ho gaya row wise dekhne ka for eg. hamare liye visually arr[1][2] ek single array jaisa hai like arr[2]. but aap wale perception se pehla wala 2 array hai of single blocks
what if i got a substring "abb" for a given range... which is not palindrome. but in your case, it shows a valid one... am i missing something or solving palindrome problem counting their occurrence is wrong approach?
0 to 25 is to get count of each letter(from a to z) between l to r. You are confusing the twi things. L to R is for array index. 0 to 25 is for a to z letters
yeah, my laptop has too much going on while recording :'( its getting from cmaers,recording its on screen and then recording ipad screen also, so it gets very slow.
@@iamluv bhaiya how to understand a given question can be solved in particular data structure and Algorithm eg: for sorted array only we can apply binary search tree
videos me jo question aapne kraya wo to samajh aa gya aur ban ja raha hai but jb mai hashing topic ka ya prefix sum ka question kisi website pe open kr raha hu to ni ban rha hai hai kya kru?????
for 1 test case there is q more testcase u can understand bt this for each test case new string will be entered but in querey test case will be on same string
#include using namespace std; const int N = 1e7 + 10; int hsh[N][26]; int main() { int t; cin >> t; while (t--) { for (int i = 0; i < N; i++) { for (int j = 0; j < 26; j++) { hsh[i][j] = 0; } } int n, q; cin >> n >> q; string s; cin >> s; for (int i = 0; i l >> r; int oddcnt = 0; for (int i = 0; i < 26; i++) { int charCt = hsh[r][i] - hsh[l - 1][i]; if (charCt % 2 != 0) { oddcnt++; } } if (oddcnt > 1) { cout
today after learning from YOUR STL series I tried to solve this questions using MAP and I was able to solve this question with help of maps and hashing even in lesser time...YOUR SOLUTION took on Average of more than 1 seconds but with help of MAP it took less than 0.5 on every test case...YOU ARE LIKE A BOON FOR ME...THANKS BROTHER..
can you please share the code so that we can also have an idea how to solve this using map?
@@komaldeepsingh6356 hey i too solved it using maps ...
#include
using namespace std;
int main()
{
int T;
cin >> T;
while(T--)
{
int n,q;
cin >> n >> q;
string s ;
cin >> s;
unordered_map < char ,vector< int >> m;
for(int i=0;i
@@__RohitDevar thnx brdr😃
Your Teaching Style is Literally Awesome
This concept helped me solving 5th question of codechef div 3 . Bahut bahut dhanyawaad bhaiya❤️
Itne details mn to koi chah k bhi nhi bna payega yh course 🔥💪
hey, did you learnt all these optimization approaches by hit n trial?
if not can you share the resources by which we can learn these optimizations?
btw very nice content, keep it up.
he had replied to some faltu comments asking his fav anime but not this one. clearly he dont want us to know all things. clearly shows his mentality
abe chutiyo editorial name ki cheese b hoti hai .....gadho
Your this mentality is completely wrong, he's an alumni of IIIT Allahabad, how will he be able to explain how he learnt these techniques, this is completely unacceptable comment
@@kartikforwork
where did iita dome bw? can you explain ur point more accurately. its a normal think to ask people how they learn it. why can't he explain it?@@shishirsaraf8498
We can be do in this way "Pre-calculate the How many letters have odd count from 0 to i. And after apply prefix sum can be found no. of odd count letter.(b/w L-R). if(no
I thought the same after 2 years
Bro this playlist is just awesome please do complete it am gonna watch it till the end!!!.
it would be less confusing if the array was declared arr[26][N] like you discussed!
Btw great playlist. Hoping to finish it soon and be better at CP. :)
Bhaiya ,mene kai saare articles/videos dekhi, but aap jesa STL kisi ne nai samjhaaya, aapka videos superrllyyyy best and unique hai bilkul, and mein ye sach me keh raha kyuki me jaanta hu mein kitna pareshan tha apne doubts ko le kar, merey saare doubts aapne clear kar li hai,,,Vesey aap aur jaada likes and subscribers deserve kartey ho🙏🏻🙏🏻🙏🏻
Thank you , sir.
Here is the code if anyone needs it.
#include
using namespace std;
const int N=1e5+10;
int hsh[N][26];
int main()
{
int t;int n; int q; cin>>t ;
while(t--)
{
cin>>n ;cin>>q ;
for (int i=0;is ;
for (int i=0;i>r ; int oddcount=0; //The concept is that if oddcount
wrong code bruv
@@kinjalkumar1900 why?
Awesome problem with awesome technique. Thanks a lot.
INT_MAX number of thankyous is also not enough for this course. Thanks a lot sirrrr...
take long long instead
one piece fans smiling while solving the question
Pre computation is best thanks for teaching us
Awesome Explanation
Luv sir, URL not found of the given problem, although this video is more than enough to solve this question...Thank-you very much
❤️
5:11 you can insert those 3 cs in the middle to make it palindrome right?
No bro bcz if we insert 3 cs after adding d in pallindrome it won't match the requirements =aabdcccbaa bcz of d its not possible. I hope this helps :)
DUDE THIS WAS " A W E S O M E "
I am watching this video on a very special occasion i.e. 1000th episode of ONE PIECE is released :)
i am really feeling very hard to learn those optimization techniques sir
Bhaiyaa, I literally love this playlist, but I request you to please, please continue this playlist again
nay nay LUV-San
finally some question which make me more exited then rest bcoz of One Piece Dressrosa Arc
I am watching atleast one video of yours everyday.
Arigato Gozaimus.
If you are reading this comment then plzz mention your fav. Arc
dressrosa
@@iamluvstill dressrosa or is it wano now😁
Wano, Dressrosa , Water 7
Great Video Series bro, Keep going on.
can you update the link of the question pls.
Amazing technique🔥🔥🔥
Bahut bahut dhanyawaad bhaiya❤️
Awesome concepts 🔥
thnks a lot ......plz upload more videos waiting........
i love that u are an one piece fan just like meee
If odd_count == 1 or 0 then it will print "YES" but how it is justified for the EVEN length sub-string to have odd_count == 1 ? If odd_count == 1 for an even length substring from L to R ..... it wont form palindrome.
For even length of substring, odd_count will have to become 0 for returning YES
@@badvelisridhar indeed
Sir, question url is invalid .
Kindly fix it .
Btw awesome explanation 🙌
What if we use map of char and int...
you can use but maps will have logn complexity, you can use unordered maps also which are o(1)
Who had come here to see this video after codeforce round 962 div3 problem C ?
Well explained!
Can we use int hsh[26] ={0}, instead of a loop assigning each index 0.
yes
Great Video !!
sir practice question link is not working
why hsh[n][26] ? not hsh[26][n] ==> 26 array with n items..???
you can use any just with slight change in code. its very similar. how i think is int a[n] is one array, so int a[n][26] are 26 arrays it just an imagination pov
@@iamluv thanks for replying 😊
The code from my side :
#include
using namespace std;
int main()
{
string x;
coutx;
int size = sizeof(x) / sizeof(x[0]);
int res[size];
int n = 0;
int st = 0;
while(x[n] != '\0')
{
// res[n] = x[n];
for(int i = 0; x[i] != '\0'; i++)
{
if(x[n]==x[i])
{
st+=1;
}
}
res[n] = st;
st = 0;
n++;
}
n = 0;
for(int i = 0; x[i] != '\0'; i++)
{
if(res[i]==1)
{
n+=1;
}
}
if(n>1)
{
cout
According to your explanation ie. for each letter one 'n' sized array, the hsh array should be hsh[26][N].
means, 26 rows and N columns and accordingly there'll be few changes(swaps) in the code. But anyways your code is working fine.
Please correct me anyone, if I am wrong.
and Thanks luv bhai.. for these explanations... for your dedicated teaching...
I am sure, I'll be a good coder one day thanks to you.❤❤
its just a matter of imagination i imagine, int hash[N] array of N integers and adding 26 once more to infront makes 26 arrays of those, what you are thinking is also correct only.
@@iamluvso..a matter of convention ! Anyways, you have already made my 2d array concept crystal clear. So thanks for giving me the opportunity to again analyse n-D array in a meaningful way. 🙏🏻🙏🏻❤️
same i was thinking like u subhasis.. but both r same, and i felt little complex what he(luv) is doing..
@@iamluv yes got it..
I was stuck there thinking just this thing and did not even complete the video. Was looking for someone to put this into comments.
Great video bhaiya
bhaiyya [26][N] ka example deke jab [N] [26] ka code likh diye to dimaag ghumne laga😅
N size ke 26 arrays banane ke liye bola example me bhi which means [N][26] only 😅, dono shi hi hai bas ye thoda sochne me idhar udhar hi jata hai...
Bhaiyya 13:30 pe dekho... aapne bola N size ke 26 arrays matlab [26][N] hua na? aur image me bhi waise hi hai..
@@Xp-Sam haan even i felt it should be [26][N] , confuse hogaya mai
N size ke 26 arrays means [N][26] , int a[n] is one array if want to make 5 such array then its like int a[n][5], putting bracket in front of anything make it an array. so existing int a[N] and then 26 arrays of that int a[N][26], but i get it why you are confused, but as i said its same thing only..
@@iamluv Yes... you are right bhaiyya,actually ham log ko aadat ho gaya row wise dekhne ka for eg. hamare liye visually arr[1][2] ek single array jaisa hai like arr[2].
but aap wale perception se pehla wala 2 array hai of single blocks
bai discord nhi join horha tumhara invitation invalid arha ha
#include
using namespace std;
int main()
{
// string str = "abcec";
// vector queries = {{1, 2}, {2, 5}, {3, 5}, {1, 5}, {1, 4}, {5, 5}};
string str = "aabbc";
vector queries = {{1, 2}, {2, 5}, {3, 5}, {1, 5}, {1, 4}};
int n = str.size();
vector res;
vector mp(26, vector(n, 0));
for (int i = 0; i < n; i++)
{
char ch = str[i];
mp[ch - 'a'][i]++;
}
for (int i = 0; i < 26; i++)
{
for (int j = 1; j < n; j++)
{
mp[i][j] += mp[i][j - 1];
}
}
for (int i = 0; i < queries.size(); i++)
{
int l = queries[i][0];
int r = queries[i][1];
l--, r--;
int numberofodd = 0;
for (int i = 0; i < 26; i++)
{
vector prefix = mp[i];
int count = prefix[r];
if (l - 1 >= 0)
count -= prefix[l - 1];
if (count % 2 == 1)
{
numberofodd++;
}
}
if (numberofodd
Beautiful ques 👍👍
why does the link to given question shows error 404! I can't find the question!
what if i got a substring "abb" for a given range... which is not palindrome. but in your case, it shows a valid one... am i missing something or solving palindrome problem counting their occurrence is wrong approach?
we reorder the obtained substring
While finding the Oddcount, we started from 0 till 25th index, but we could have used from l till r, right?
0 to 25 is to get count of each letter(from a to z) between l to r. You are confusing the twi things. L to R is for array index. 0 to 25 is for a to z letters
bro ur ques link is not opening
i was way tooo close to the solution. Only did a minute mistake. Next time I WILL SOLVE these type of question
The link to the problem is not working, can anyone give the updated link?
Hello bro,please make cp questions list . Which help to understand all dsa topic
Warning: do not use the name 'hash' as your hash array.
i used hsh and not hash, you should not use hash as hash is a reserved keyword in c/c++
@@iamluv Haan bhaiya stackoverflow helped me. I was re-attempting the question and wasted so much time on debugging.
"[Finished in 56.8s]" lmfao
yeah, my laptop has too much going on while recording :'( its getting from cmaers,recording its on screen and then recording ipad screen also, so it gets very slow.
@@iamluv bhaiya how to understand a given question can be solved in particular data structure and Algorithm eg: for sorted array only we can apply binary search tree
videos me jo question aapne kraya wo to samajh aa gya aur ban ja raha hai but jb mai hashing topic ka ya prefix sum ka question kisi website pe open kr raha hu to ni ban rha hai hai kya kru?????
for the 2nd testcase [1,2]="aa" is palindrome ,but you have given NO as answer
Right now, i am watching the same episode of One piece
awesome
Finger at 4:49
bhaiya competetive programming start krne ke liye pura course complete krna pdega yaa abhi mai contest de skta hu!
bro i tried to visit the question but it says that invalid url
Luv bhaiya orz 🔥
Can someone tell me the problem name as the link is not working for me
🙏🏻 🙏🏻Sir, aap padhate waqt highlight krne ke liye konsa softwate use krte ho (jo laser jaisa dikhta hai phir apne aap gayab ho jata hai) 🙏🏻🙏🏻
vo ipad ka software h inbuild
link for that problem is not working
Bro I m 2nd year student and I spent lot of time doing web dev works .now I m kind of going to start competitive programming am I late 😭.
no, just follow the course and practice a lot, you will be able to do it.
Which sem bro?
@@ShubhamVerma-hw4uj bro are you from lko?
Best❤️❤️❤️
problem link is not working. please give me the link
now the problem ain't available anymore
ye hard ques to kuch jada he complex hai. 26 array banane the but phir aapne khidi paka di
Linl of the question is not working
question link is invalid now :/
Bhaiya your questions link is not working
bhaiya aapne one piece dekhi h?
haa
@@iamluv favorite anime bhaiya aapka?
@@iamluv bhaiya whitebeard ko weak dikhaya tha na marineford m ???kya vichar h bhaiya
Bhaiya , Goku > Saitama na?
@@siddharthadeo9944 obviously bhai..... Ye bhi koi puchne wala question h😔
@Luv aababaa here a is coming 5 times but it is a plidrm please help
6:38
op supermacy🤩
please look into it .. the problem link given in description is not working
yes its not working for me also, its some hackerearth server issue, not sure what can be done here.
spoiler de diye bhai one piece ka😭😭😭😭😭
bhayia problem link is not working ....khulne pr blank screen aa rhi hai .....tried on mobile too
Which link?
@@iamluv link to the problem you have discussed in this video
@@iamluv please look into it .. the problem link given is not working
yeah its not working for me also, its some hackerearth issue link is correct but its not working, not sure why
Anyone please tell me what is the difference between test cases (t) and queries (q) ??
for 1 test case there is q more testcase u can understand bt this
for each test case new string will be entered but in querey test case will be on same string
they are basically treated same
bhai agar source code provide kara dete to bahut help ho jati, btw thanks
bro problem link not working
question link
thank you
ur explanantion is awesome bro. try making courses at udemy and other platforms.it would make you a fortune
Attendance 16
error a rhi he sir
Thank you bhaiya 🙇🏻
Hands down
2 yellow heart
bro link to this question is not working :(
I know, its a hackerearth issue :(
OP fan, I see.🌚
Question's link isn't active......
yes, its hackerearth issue, you can find similar questions in the contest of precomputation
Nice
Bhaiya when is binary search coming?
ayega jldi hi
@@iamluv Ok bhaiya
anime and coding
#include
using namespace std;
const int N = 1e7 + 10;
int hsh[N][26];
int main()
{
int t;
cin >> t;
while (t--)
{
for (int i = 0; i < N; i++)
{
for (int j = 0; j < 26; j++)
{
hsh[i][j] = 0;
}
}
int n, q;
cin >> n >> q;
string s;
cin >> s;
for (int i = 0; i l >> r;
int oddcnt = 0;
for (int i = 0; i < 26; i++)
{
int charCt = hsh[r][i] - hsh[l - 1][i];
if (charCt % 2 != 0)
{
oddcnt++;
}
}
if (oddcnt > 1)
{
cout
Just a comment to increase reach