Skip to content

Commit abd0780

Browse files
authored
Create String-Fewer Notes
1 parent e9a9a79 commit abd0780

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

String-Fewer Notes

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
problem statement
3+
4+
https://www.codingninjas.com/codestudio/contests/codestudio-weekend-contest-53/7079253/problems/23064?leftPanelTab=0
5+
6+
7+
8+
9+
10+
11+
public class Solution {
12+
static int aString(int x, int y, String s) {
13+
char ch[] = s.toCharArray();
14+
int count = 0 ;
15+
if(ch[0] == 'b')count =1 ;
16+
17+
for(int i =1; i<s.length() ;i++){
18+
if(ch[i] == 'b' && ch[i-1] == 'a'){
19+
count++;
20+
}
21+
}
22+
23+
if(count == 0)return 0;
24+
return y + (count -1) * Math.min(x , y);
25+
}
26+
}

0 commit comments

Comments
 (0)