Decode the string | Problem of the Day: 11/10/22 | Siddharth Hazra

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ม.ค. 2025

ความคิดเห็น • 16

  • @suhilxd1473
    @suhilxd1473 ปีที่แล้ว +1

    Is there any way to solve it with idea of stackst; where we wont have to add long length of string, char by char into stack again and again

  • @syedshasuheb709
    @syedshasuheb709 ปีที่แล้ว

    sir really i was searching for the answer for this particular question in youtbe but no one explained as u did sir. thank u sir

  • @nithishkumarramasamy9985
    @nithishkumarramasamy9985 5 หลายเดือนก่อน

    for Java
    class Solution{
    static String decodedString(String s){
    Stack numStack = new Stack();
    Stack sbStack = new Stack();
    StringBuilder currStr = new StringBuilder();
    int timesNum =0;
    for(char c: s.toCharArray()){
    if(Character.isDigit(c)){
    timesNum = timesNum *10 +(c-'0');
    }
    else if(c=='['){
    numStack.push(timesNum);
    timesNum =0;
    sbStack.push(currStr);
    currStr = new StringBuilder();
    }else if(c==']'){
    StringBuilder temp = currStr;
    int times = numStack.pop();
    currStr = sbStack.pop();
    while(times>0){
    currStr.append(temp);
    times--;
    }
    }else{
    currStr.append(c);
    }
    }
    return currStr.toString();
    }
    }

  • @mohitsigchi
    @mohitsigchi 2 ปีที่แล้ว +1

    Nice explaination 👍

  • @krishxftw7508
    @krishxftw7508 2 ปีที่แล้ว +1

    Sir , Nice Explanation

  • @shivkantgupta1378
    @shivkantgupta1378 2 ปีที่แล้ว

    Sir what is mean stack allowed for vector 2

  • @ProGamer-hj6jj
    @ProGamer-hj6jj 2 ปีที่แล้ว

    terminate called after throwing an instance of 'std::invalid_argument'
    what(): stoi my error

  • @shubhamanand2593
    @shubhamanand2593 ปีที่แล้ว +1

    time limit exceeds for this approach, thats why he hasn't run his code in this video

  • @b.jayanagavarmavarma191
    @b.jayanagavarmavarma191 2 ปีที่แล้ว

    same code in java gives time limit exceed

    • @siddhartha166
      @siddhartha166 2 ปีที่แล้ว

      please check again

    • @Anurag-kp6wc
      @Anurag-kp6wc 2 ปีที่แล้ว

      Use StringBuilder instead of Strings.

  • @bpkperwakilanprovinsiriau7167
    @bpkperwakilanprovinsiriau7167 2 ปีที่แล้ว

    THANK YOU!!! TNice tutorials is such an amazing tutorial. I just got soft soft today and was playing around on it but had no clue how to really use it.