We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7980c4e commit 26229d2Copy full SHA for 26229d2
880. Decoded String at Index
@@ -0,0 +1,33 @@
1
+Runtime 0 ms
2
+Beats 100%
3
+
4
5
+Memory 40.2 MB
6
+Beats 55.51%
7
8
9
+class Solution {
10
+ public String decodeAtIndex(String s, int k) {
11
+ long size=0;
12
13
+ for(char c:s.toCharArray()){
14
+ if(Character.isDigit(c))
15
+ size=size*(c-'0');
16
+ else
17
+ size++;
18
+ }
19
20
+ for(int i=s.length()-1;i>=0;i--){
21
+ char c=s.charAt(i);
22
+ k%=size;
23
+ if((k==0 || k==size) && Character.isLetter(c))
24
+ return Character.toString(c);
25
26
+ size=size/(c-'0');
27
28
+ size--;
29
30
31
+ return null;
32
33
+}
0 commit comments