DSA Phir se with Sumeet | Leetcode 14 | Longest Common Prefix

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 11

  • @JyotismanBehera-wv1ru
    @JyotismanBehera-wv1ru 10 місяців тому

    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 .

  • @UmaTrilok-c1v
    @UmaTrilok-c1v 11 місяців тому +1

    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

  • @umangbehl8152
    @umangbehl8152 11 місяців тому +4

    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

  • @brp3522
    @brp3522 2 місяці тому

    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;

  • @ATULKUMAR-pk9kj
    @ATULKUMAR-pk9kj 11 місяців тому +3

    Sir , is it also for experience ?

    • @Pepcoding
      @Pepcoding  11 місяців тому +2

      Ye to 4 saal ki engineering hai. Experienced ke liye 1.5 years ka course hai.

  • @onkarhol
    @onkarhol 11 місяців тому

    thank you 🥰🥰

  • @viralmathura
    @viralmathura 10 місяців тому

    bro, can u update the leetcode 75 playist as soon as possible

  • @ronakgupta200
    @ronakgupta200 11 місяців тому

    code force sir pls

  • @indian_gaurav_8648
    @indian_gaurav_8648 11 місяців тому

    kaash language c++ hoti