public String longestCommonPrefix(String[] strs) { Arrays.sort(strs); String smallest = strs[0]; String longest = strs[strs.length-1]; int index = 0; while(index < smallest.length() && index < longest.length()){ if(smallest.charAt(index) == longest.charAt(index)){ index++; }else{ break; } } return strs[0].substring(0,index); } All thanks goes to sumeet sir , whose dsa level 1 made me think crazy way to solve such problems .
Hi Sumeet Sir, I am glad that you started Leetcode problems again. I have been following your pep-coding content for two years now, I am a Data Engineer for 9 years and more or less I spend 60% of my time on data and I will have very less time for programming, for any good companies to crack the interview coding is mandatory for senior levels(hence following your videos). Can you please make one more DSA list which is suitable for Data Engineers? Thank you, Uma
with due respect sir can you make a daily video of problem of the day of leetcode it will be good to learn from you when we are unable to solve it onty one person is doing it so far by providing good intuition rest all just tell solution
public String longestCommonPrefix(String[] strs) {
Arrays.sort(strs);
String smallest = strs[0];
String longest = strs[strs.length-1];
int index = 0;
while(index < smallest.length() && index < longest.length()){
if(smallest.charAt(index) == longest.charAt(index)){
index++;
}else{
break;
}
}
return strs[0].substring(0,index);
}
All thanks goes to sumeet sir , whose dsa level 1 made me think crazy way to solve such problems .
Hi Sumeet Sir,
I am glad that you started Leetcode problems again. I have been following your pep-coding content for two years now, I am a Data Engineer for 9 years and more or less I spend 60% of my time on data and I will have very less time for programming,
for any good companies to crack the interview coding is mandatory for senior levels(hence following your videos). Can you please make one more DSA list which is suitable for Data Engineers?
Thank you,
Uma
with due respect sir can you make a daily video of problem of the day of leetcode it will be good to learn from you when we are unable to solve it onty one person is doing it so far by providing good intuition rest all just tell solution
Okay
To anyone's having TLE because of all the added edge cases :
if(strs == null || strs.length == 0) {
return "";
}
String prefix = strs[0];
for(int i=1; i < strs.length; i++) {
while(strs[i].indexOf(prefix) != 0) {
prefix = prefix.substring(0, prefix.length() - 1);
if(prefix.isEmpty()) {
return "";
}
}
}
return prefix;
Sir , is it also for experience ?
Ye to 4 saal ki engineering hai. Experienced ke liye 1.5 years ka course hai.
thank you 🥰🥰
bro, can u update the leetcode 75 playist as soon as possible
code force sir pls
kaash language c++ hoti