Arrays & Strings

Print Consecutive Occurrences of Each Character in String Java

Posted on

Problem Statement: Write a program to print consecutive occurrences of each character in a given string.

Test case 1:
Input : affffssdaaag
Output: a1f4s2d1a3g1

Test case 2:
Input: affffssdaaa
Output: a1f4s2d1a3

Test case 3:
Input: aaa
Output: a3 Read the rest of this entry »

Count Occurrences of Character in a String Java

Posted on Updated on

Problem Statement: Write a program to count occurrence of each character in a given string.

Test case 1:
Input : aabacghc
Output: a3b1c2g1h1

Test case 2:
Input: aaabbcccc
Output: a3b2c4 Read the rest of this entry »

Check balanced brackets, braces, parenthesis

Posted on

One of the famous interview question asked is to check if the given string has proper completion of string. This question is twisted and asked in various way, either check for brackets or any one of the bracket, braces or parenthesis or all. Read the rest of this entry »