ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
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
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
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(); }}
Nice explaination 👍
Thank u
Sir , Nice Explanation
Thank you
Sir what is mean stack allowed for vector 2
I didn't get your query
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi my error
time limit exceeds for this approach, thats why he hasn't run his code in this video
same code in java gives time limit exceed
please check again
Use StringBuilder instead of Strings.
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.
Thank you so much
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
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
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();
}
}
Nice explaination 👍
Thank u
Sir , Nice Explanation
Thank you
Sir what is mean stack allowed for vector 2
I didn't get your query
terminate called after throwing an instance of 'std::invalid_argument'
what(): stoi my error
time limit exceeds for this approach, thats why he hasn't run his code in this video
same code in java gives time limit exceed
please check again
Use StringBuilder instead of Strings.
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.
Thank you so much