Skip to content

Commit

Permalink
Add frequency string 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
debapriyo007 committed Oct 1, 2023
1 parent 79754e7 commit 9785ada
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Binary file added 08_String/prb.class
Binary file not shown.
22 changes: 22 additions & 0 deletions 08_String/prb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public class prb {
public static String getFre(String str){
int fre[]= new int[26];
for(char ch : str.toCharArray()){
fre[ch-'a']++;
}

StringBuilder sb = new StringBuilder("");
char c = 'a';
for(int i : fre){
sb.append(c);
sb.append(i);
c++;
}
return sb.toString();

}
public static void main(String[] args) {
String strs = "aabbc";
System.out.println(getFre(strs));
}
}

0 comments on commit 9785ada

Please sign in to comment.