Smart Coding & Interview Series
Top-20 Basic Program
(1-D Array Applications)
First, understand the solution building strategies and coding for the problems in
LIVE/VIDEO session and then you apply those strategies discussed in
LIVE/VIDEO session to solve the following problems. Use your favourite
language(C/C++/Java/C#/Python/Scala) for coding.
1) First Unique Character in a String: Given a string, find the first non-repeating character
in it and return its index. If it doesn't exist, return -1. Assume that only lower case letters are
allowed as part of string.
Example:
S=”algorithmica’
Return 1
Source:[Link]
2) First Repeated Character in a String: Given a string, find the first repeating character in it
and return its index. If it doesn't exist, return -1. Assume that only lower case letters are
allowed as part of string.
Example:
S=”algorithmica’
Return: 0
3) Remove Characters in a String: Given a string, find an efficient algorithm that takes two
strings as arguments and removes the characters from first string which are present in
second string. Assume that only lower case letters are allowed as part of strings and relative
order of characters in first string must be preserved.
Example:
S1=”algorithmica’ S2=’aio’
Return: lgrthmc
4) Most Frequent Character in a String: Find an efficient algorithm that returns the most
frequent character in a given string. In case of tie, return any character. Assume that only
lower case letters are allowed as part of string.
Example:
S=”algorithmica’
Return: a or i
Copyright © Algorithmica
[Link]