Validate an IP Address | String | GFG POTD | C++ | Java | Code Kar Lo

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

КОМЕНТАРІ • 16

  • @mrdeath9132
    @mrdeath9132 Місяць тому +1

    Sir What a Beautiful Explanation

  • @NiazNiaz-y9c
    @NiazNiaz-y9c Місяць тому

    well and informative explain vaiya💖

  • @arnab027
    @arnab027 Місяць тому +2

    First time I am facing this problem
    I submitted a wrong code which passed all tc
    After watching ur video I realized that I did a small wrong for which code should not run
    And surprisingly now i am trying to submit the old code which was accepted it is showing Rte 😅

    • @AMANKUMAR-bt6cw
      @AMANKUMAR-bt6cw Місяць тому

      Sometimes GFG changes the test cases.
      I also faced the same problems a few times.

    • @arnab027
      @arnab027 Місяць тому

      @@AMANKUMAR-bt6cw achha

    • @code_kar_lo
      @code_kar_lo  Місяць тому

      Yes gfg changes the test cases.

  • @salmaniproductions1104
    @salmaniproductions1104 Місяць тому

    Solved on my own, Thank you bhaiyya

  • @kshitijsingh8754
    @kshitijsingh8754 Місяць тому

    if (str[index + 1] == '0' && i - index - 1 > 1) return false;
    if (str[index + 1] == '0' && str.length() - index - 1 > 1) return false;
    for checking leading zeros at start and end

  • @aizad786iqbal
    @aizad786iqbal Місяць тому

    i solved on my own, but they changed test cases, did few modifications now , working fine
    idk why they do this...
    btw we can use regex to solve these type of problem also....
    I will try that later...
    and ye technically TC bhi O(1) hua an since str length is 15 max....

    • @code_kar_lo
      @code_kar_lo  Місяць тому

      Hn string ki length bohat jyada nhi hogi

  • @mohitjain9402
    @mohitjain9402 Місяць тому

    public boolean isValid(String str) {
    String[] arrOfStr = str.split("\\.");

    if(arrOfStr.length != 4){
    return false;
    }
    for(int i=0;i 1) && (arrOfStr[i].charAt(0)) == '0' ){
    return false;
    }
    int x=Integer.parseInt(arrOfStr[i]);
    if(x

    • @pain9569
      @pain9569 Місяць тому

      sahi hai bhai, mera bhi same logic hi tha bs andr
      int val = Integer.parseInt(arr[i]);
      if(val255){
      return false;
      }
      ye inner loop m code tha sare tc pass kr gye