Problem
#1:
Your program will take an input string, S (containing only lower-case alphabets) and print the first
distinct character in S. Your program
should run in O (n) and utilize only two integer arrays, each of size
=26
Example:
S = abcabcfd
First distinct character in S = f
Problem #2: Given two input words, A and B, write a program to check
if the two words are anagrams or not.
Your program must run in O (N) and utilize only two integer
arrays, each of size =26
Examples:
#1:
Input first
word: imagine
Input second
word: maginei
The words
are anagrams
#2:
Input first
word: apple
Input second
word: snapl
The words
are not anagrams
#3:
Input first
word: because
Input second
word: beam
The words
are not anagrams
Problem #3:
Your
program will take a string input, S.
The input will consist only of 0s and 1s as the characters. Your program should
compute the total number of substrings in S
that start and end with 1.
If S =
“10001001”, the following substrings in S
start and end with 1:
· 10001
· 1001
· 10001001
For the above
example, your output must be 3. You don’t have to print all the substrings in S
that start and end in 1. Your program must run in O (n) and utilize a space of
O (1).