Web Programming - Code Test
[Link]
TIME PERIOD : 2 HOURS
Terms and conditions:
● You are allowed to use any programming language to solve these
problems
● Avoid using inbuilt methods/apis provided by the programming language.
● Solve any 4 problems out of 8
● Mail zipped file to info@[Link]
● This code test is specific for candidates with 0-1yr programming
experience.
● All the challenges will have a predetermined score.
● Please refrain from discussing strategy during the contest.
● Any case of code plagiarism will result in disqualification of both the users
from the contest. We've a fairly good plagiarism detector that works at the
opcode level.
0
Web Programming - Code Test
[Link]
ONE
Given an array C of size N
-1 and given that there are numbers from 1 to N
with one element missing, the missing number is to be found.
Input:
The first line of input contains an integer T denoting the number of test cases.
For each test case first line contains N
(size of array). The subsequent line
contains N-1 array elements.
Output:
Print the missing number in array.
Constraints:
1 ≤ T ≤ 200
1 ≤ N ≤ 107
1 ≤ C[i] ≤ 107
Example:
Input:
2
5
1
Web Programming - Code Test
[Link]
1 2 3 5
10
1 2 3 4 5 6 7 8 10
Output:
4
9
Explanation:
Testcase 1: Given array : 1 2 3 5. Missing element is 4.
2
Web Programming - Code Test
[Link]
TWO
Given an input stream of N integers. The task is to insert these numbers into a
new stream and find the median of the stream formed by each insertion of X
to the new stream.
Input:
The first line of input contains an integer N denoting the number of elements
in the stream. Then the next N lines contains integer x denoting the number
to be inserted into the stream.
Output:
For each element added to the stream print the floor of the new median in a
new line.
Constraints:
1 <= N <= 106
1 <= x <= 106
Example:
Input:
4
3
Web Programming - Code Test
[Link]
5
15
1
3
Output:
5
10
5
4
Explanation:
Testcase 1:
Flow in stream : 5, 15, 1, 3
5 goes to stream --> median 5 (5)
15 goes to stream --> median 10 (5, 15)
1 goes to stream --> median 5 (5, 15, 1)
3 goes to stream --> median 4 (5, 15, 1, 3)
4
Web Programming - Code Test
[Link]
THREE
Given a String of length S, reverse the whole string without reversing the
individual words in it. Words are separated by dots.
Input:
The first line contains T denoting the number of testcases. T testcases follow.
Each case contains a string S containing characters.
Output:
For each test case, in a new line, output a single line containing the reversed
String.
Constraints:
1 <= T <= 100
1 <= |S| <= 2000
Example:
Input:
2
[Link]
[Link]
Output:
[Link].i
[Link]
5
Web Programming - Code Test
[Link]
Four
Given a string s, recursively remove adjacent duplicate characters
from the string s. The output string should not have any adjacent
duplicates.
Input:
The first line of input contains an integer T, denoting the no of test
cases. Then T test cases follow. Each test case contains a string str.
Output:
For each test case, print a new line containing the resulting string.
Constraints:
1<=T<=100
1<=Length of string<=50
Example:
Input:
2
sppritlleewoorkwiith
Acaaabbbacdddd
Output:
spritleworkwith
acac
6
Web Programming - Code Test
[Link]
FIVE
Given two strings a and b consisting of lowercase characters. The task is to
check whether two given strings are anagram of each other or not. An
anagram of a string is another string that contains same characters, only the
order of characters can be different. For example, “act” and “tac” are anagram
of each other.
Input:
The first line of input contains an integer T denoting the number of test cases.
Each test case consist of two strings in 'lowercase' only, in a single line.
Output:
Print "YES" without quotes if the two strings are anagram else print "NO".
Constraints:
1 ≤ T ≤ 300
1 ≤ |s| ≤ 1016
Example:
Input:
2
geeksforgeeks forgeeksgeeks
allergy allergic
Output:
YES
7
Web Programming - Code Test
[Link]
NO
Explanation:
Testcase 1: Both the string have same characters with same frequency. So,
both are anagrams.
Testcase 2: Characters in both the strings are not same, so they are not
anagrams.
8
Web Programming - Code Test
[Link]
SIX
Given a array of N strings, find the longest common prefix among all strings
present in the array.
Input:
The first line of the input contains an integer T which denotes the number of
test cases to follow. Each test case contains an integer N. Next line has space
separated N strings.
Output:
Print the longest common prefix as a string in the given array. If no such prefix
exists print "-1"(without quotes).
Constraints:
1 <= T <= 103
1 <= N <= 103
1 <= |S| <= 103
Example:
Input:
2
4
geeksforgeeks geeks geek geezer
9
Web Programming - Code Test
[Link]
3
apple ape april
Output:
gee
ap
Explanation:
Testcase 1: Longest common prefix in all the given string is gee.
10
Web Programming - Code Test
[Link]
SEVEN
Programs to print triangles using *, numbers and characters
Example:
Input:
5
7
Output:
*
* *
* * *
* * * *
* * * * *
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
11
Web Programming - Code Test
[Link]
EIGHT
Given a matrix m at[][] of size M *N. Traverse and print the matrix in spiral
form.
Input:
The first line of the input contains a single integer T, denoting the number of
test cases. Then T test cases follow. Each testcase has 2 lines. First line
contains M and N respectively separated by a space. Second line contains
M*N values separated by spaces.
Output:
Elements when travelled in Spiral form, will be displayed in a single line.
Constraints:
1 <= T <= 100
2 <= M,N <= 10
0 <= Ai <= 100
Example:
Input:
2
4 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3 4
1 2 3 4 5 6 7 8 9 10 11 12
Output:
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
1 2 3 4 8 12 11 10 9 5 6 7
12
Web Programming - Code Test
[Link]
13