import java.util.*; class Solution { public static void main(String[] args) { String str = "sinstriiintng"; int[] counts = new int[26]; for (int i = 0; i < str.length(); i++) counts[str.charAt(i) - 'a']++; for (int i = 0; i < 26; i++) if (counts[i] > 1) System.out.println((char)(i + 'a') + " - " + counts[i]); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter