class Solution { public String shiftingLetters(String str, int[][] shifts) { StringBuilder ans = new StringBuilder(); int []pre = new int[str.length()]; for(int arr[] : shifts){ int s=arr[0]; int e=arr[1]; int d=arr[2]; if(d==0){ pre[arr[0]]--; if(arr[1]+1
Sometimes after so much effort put into thinking how to solve the potd, and then watching your solution feels like, thank you God for his(your) existence. Really man thank you. btw motivation in the beginning, something which was very much needed. Love and respect always.
Sharing code of Shifting Letter I and II (If someone wants to see) : Shifting Letters | : class Solution { public: string shiftingLetters(string s, vector& shifts) { int n = s.size(); vector rangeUpdates(n + 1, 0); int q = shifts.size();
for (int i = 0; i < q; i++) { int start = 0; int end = i; int value = shifts[i];
I solved Leetcode-370 also and this problem also after watching the first video of this playlist. I never knew about Difference Array Technique, all thanks to you LEGEND MIK
sir this is how solved today's POTD question after watching your intuition video : class Solution { public: string shiftingLetters(string s, vector& shifts) { int n = s.size(); vectorvec(n,0); for(auto& shift : shifts){ int left = shift[0]; int right = shift[1]; int x = shift[2]; if(x == 1){ vec[left] += 1; if(right + 1 < n){ vec[right+1] += -1; } } else{ vec[left] += -1; if(right + 1 < n){ vec[right+1] += 1; } } } for(int i=1;i
Sir, please make an explanation video on Todays 3rd leetcode contest problem. At first it looks like the difference array problem but a harder one I guess.
Here is the similar java code : class Solution { public String shiftingLetters(String s, int[][] shifts) { int n = s.length(); int diff[] = new int[n];
for(int shift[] : shifts){ int left = shift[0]; int right = shift[1]; int x = shift[2] == 1 ? 1 : -1; diff[left] += x; if(right+1 < n){ diff[right+1] -= x; } } // find cumilative sum for(int i=1;i
sir ye aap ek hi video me bhi bata sakte the na where there is need of separate video. Because this video entirely dependent on the first video that's why I'm saying. ab mujhe copy and past karke code submit karna pada is reason se
Start by studying concepts first and build fundamentals. Always remember that we must study DSA topic by topic . First study the topic’s concepts, then solve good Questions on them. Then move to next topic and so on. I usually create two playlists for every topic : 1) Concepts Playlist - Contains from basic concepts to expert concepts. 2) Popular Interview Problems playlist. I have created concepts and interview problems playlist for 1) Graph 2) Recursion 3) DP 4) Segment Tree Planning soon to create concepts playlist for Tree as well. Graph Concepts - ruclips.net/p/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY&si=lZG2IJTmSW4kRrx- Graph Popular Interview Problems - ruclips.net/p/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO&si=CG2JvGWVmvoSqvWA Recursion Concepts - ruclips.net/p/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM&si=614iI4NyHY-FTeJH Recursion Problems (In progress) - ruclips.net/p/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO&si=88fBhRnr62OYTnDP DP Concepts (In progress) - ruclips.net/p/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt&si=laFVYy6ep2BkOg0s DP Popular interview problems - ruclips.net/p/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3&si=VHEn9b-wqTnAVyyi Segment Tree Concepts - ruclips.net/p/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB&si=xm7DqRN4H0eZwna4 Difference Array Technique : Concepts & Qns - ruclips.net/p/PLpIkg8OmuX-Kqkb8DqDe_4-Tiav6ilS_L&si=uLVaa_-YYretZUzE
Sir In recent contest (weekly contest 431) , leetcode 3413, difference array technique se solve kr rha hu toh memory exceed de rha ...app ek video ye question pe bna dete toh kaffi help ho jatta
but sir only the problem is that from youside eveything is ok but i have been solving leedcode from 1 and half year till now i am not able to solve contest question 3 and 4
Thank you sir jo aapne isse pehle wali video upload ki thi usi concept se mene ye problem solve kr li
class Solution {
public String shiftingLetters(String str, int[][] shifts) {
StringBuilder ans = new StringBuilder();
int []pre = new int[str.length()];
for(int arr[] : shifts){
int s=arr[0];
int e=arr[1];
int d=arr[2];
if(d==0){
pre[arr[0]]--;
if(arr[1]+1
same bhai
❤️🔥
thank you, i could code it watching your intuition from the other video and taking ideas from other's code
bas aaj ke baad kabhi difference array technique wali problems mei TLE nahi khaunga thank you so much🙏
Thanks a lot. Difference array technique is crystal clear now.
Sometimes after so much effort put into thinking how to solve the potd, and then watching your solution feels like, thank you God for his(your) existence. Really man thank you. btw motivation in the beginning, something which was very much needed. Love and respect always.
I’m glad you enjoyed the video! Thanks for the kind words. 🙏
Choti se choti chiz, aapne itne aache se samzaya h, bhaiya.
Lots of love 💗
Sharing code of Shifting Letter I and II (If someone wants to see) :
Shifting Letters | :
class Solution {
public:
string shiftingLetters(string s, vector& shifts) {
int n = s.size();
vector rangeUpdates(n + 1, 0);
int q = shifts.size();
for (int i = 0; i < q; i++) {
int start = 0;
int end = i;
int value = shifts[i];
rangeUpdates[start] += value;
if (end + 1 < n) {
rangeUpdates[end + 1] -= value;
}
}
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += rangeUpdates[i];
sum = (sum % 26 + 26) % 26;
s[i] = (s[i] - 'a' + sum) % 26 + 'a';
}
return s;
}
};
Shifting Letters || :
class Solution {
public:
string shiftingLetters(string s, vector& shifts) {
int n = s.size();
vector rangeUpdates(n + 1, 0);
int q = shifts.size();
for (int i = 0; i < q; i++) {
int start = shifts[i][0];
int end = shifts[i][1];
int direction = shifts[i][2];
rangeUpdates[start] += (direction == 1 ? 1 : -1);
if (end + 1 < n) {
rangeUpdates[end + 1] -= (direction == 1 ? 1 : -1);
}
}
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += rangeUpdates[i];
sum = (sum % 26 + 26) % 26;
s[i] = (s[i] - 'a' + sum) % 26 + 'a';
}
return s;
}
};
Thanks bhai
Thank u sir apke approach too good ❤❤
Thanks, I already have solved the problem. Just came here to keep up my consistent and learn something new.
Very helpful bhaiya ❤
Lovely motivation bhaiya ❤❤
Bhaiya apka channel bahut underrated hai , your channel deserves millions subscribers❤❤
MIK you're awesome 😎
Thank you for today's lecture.
bhaiyya you are having long videos but are worth watching🤟💯
Sloved this question using brute force approach and 37/39 testcases passed.
I solved Leetcode-370 also and this problem also after watching the first video of this playlist. I never knew about Difference Array Technique, all thanks to you LEGEND MIK
bhaiya, i was searching for your video since morning to solve POTD !!
Sir weekly aur bi-weekly contest ke solutions bhi bna diya karo ❤
Thanks bhai ❤❤
sir this is how solved today's POTD question after watching your intuition video :
class Solution {
public:
string shiftingLetters(string s, vector& shifts) {
int n = s.size();
vectorvec(n,0);
for(auto& shift : shifts){
int left = shift[0];
int right = shift[1];
int x = shift[2];
if(x == 1){
vec[left] += 1;
if(right + 1 < n){
vec[right+1] += -1;
}
}
else{
vec[left] += -1;
if(right + 1 < n){
vec[right+1] += 1;
}
}
}
for(int i=1;i
Thank you for uploading
Thanks
1943 que leetcode , is exactly difference array techinque question 😊
Thanks 👌🏻
First 🎉❤
6:20 indirectly kar toh hum update hee rhe hain na string ki value ko usko backward and forward move karke ?
We can call line sweep algorithm
yeah need this one ASAP....
Sir, please make an explanation video on Todays 3rd leetcode contest problem. At first it looks like the difference array problem but a harder one I guess.
bhaiya please cover concept like rolling hash
Here is the similar java code :
class Solution {
public String shiftingLetters(String s, int[][] shifts) {
int n = s.length();
int diff[] = new int[n];
for(int shift[] : shifts){
int left = shift[0];
int right = shift[1];
int x = shift[2] == 1 ? 1 : -1;
diff[left] += x;
if(right+1 < n){
diff[right+1] -= x;
}
}
// find cumilative sum
for(int i=1;i
public String shiftingLetters(String s,int[][]shifts){
char[]c=s.toCharArray();
int n=c.length;
int[]diff=new int[n];
for(int[]shift:shifts){
if(shift[2]==0){
diff[shift[0]]--;
if(shift[1]+1
cat lover❤attendance 🐈⬛🐈
Bhaiya please make a video on leetcode biweekly 147 question number 3(Longest Subsequence with decreasing adjacent difference) 🙏
Sir can u add links of other similar questions on topic from leetcode/gfg in the description. It would be really helpful.
*on this topic
I HAVE A TWO PASS SOLUTION FOR THIS PLEASE REFER TO THIS,
int n = s.size();
vector diff(n , 0);
for (auto& q : shifts) {
int direction = q[2] == 0 ? -1 : 1;
diff[q[0]] += direction;
if (q[1] + 1 < n) {
diff[q[1] + 1] -= direction;
}
}
int shift = 0;
for (int i = 0; i < n; ++i) {
shift += diff[i];
int effectiveShift = (shift % 26 + 26) % 26;
s[i] = 'a' + (s[i] - 'a' + effectiveShift) % 26;
}
return s;
sir ye aap ek hi video me bhi bata sakte the na where there is need of separate video. Because this video entirely dependent on the first video that's why I'm saying. ab mujhe copy and past karke code submit karna pada is reason se
Nice thumbnail
bhaiya leetcode q-43 explain kardo easy way me
bhaiya beginner hu abhi dsa kar raha hu daily problem solve karu abhi ya phir dsa karne ke baad start karu
Start by studying concepts first and build fundamentals.
Always remember that we must study DSA topic by topic . First study the topic’s concepts, then solve good Questions on them. Then move to next topic and so on.
I usually create two playlists for every topic :
1) Concepts Playlist - Contains from basic concepts to expert concepts.
2) Popular Interview Problems playlist.
I have created concepts and interview problems playlist for
1) Graph
2) Recursion
3) DP
4) Segment Tree
Planning soon to create concepts playlist for Tree as well.
Graph Concepts - ruclips.net/p/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY&si=lZG2IJTmSW4kRrx-
Graph Popular Interview Problems - ruclips.net/p/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO&si=CG2JvGWVmvoSqvWA
Recursion Concepts - ruclips.net/p/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM&si=614iI4NyHY-FTeJH
Recursion Problems (In progress) - ruclips.net/p/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO&si=88fBhRnr62OYTnDP
DP Concepts (In progress) - ruclips.net/p/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt&si=laFVYy6ep2BkOg0s
DP Popular interview problems - ruclips.net/p/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3&si=VHEn9b-wqTnAVyyi
Segment Tree Concepts -
ruclips.net/p/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB&si=xm7DqRN4H0eZwna4
Difference Array Technique : Concepts & Qns - ruclips.net/p/PLpIkg8OmuX-Kqkb8DqDe_4-Tiav6ilS_L&si=uLVaa_-YYretZUzE
@codestorywithMIK thanks bhaiya ☺️
sir kya aap please contest k solutions bhi la skte h kya , aapke alawa kisi aur se samaj hi nhi aaata h??????????????
Sundar++
I couldn't figure the answer for contest 3rd question please make a video sit😊
Leetcode Contest video solution in case you want - ruclips.net/video/LhsqM-9-gNk/видео.html&ab_channel=KumarK%5BAmazon%5D .
Sir In recent contest (weekly contest 431) , leetcode 3413, difference array technique se solve kr rha hu toh memory exceed de rha ...app ek video ye question pe bna dete toh kaffi help ho jatta
but sir only the problem is that from youside eveything is ok but i have been solving leedcode from 1 and half year till now i am not able to solve contest question 3 and 4
1st video ka link?
ruclips.net/video/ZHNVmtm08WY/видео.htmlsi=B2-5JyTwLbhdcSij
❤️
i was searching for your video, before you upload it🫣thanks
Thank you so much bhaiya for this awesome new technique. ❤🫡
In last, to map index, I had used this.
for(int i=0; i