Player PDF
Player PDF
SET-1
Input Size : |s| <= 100000 (ie do it in O(n) or O(log n) time complexity)
Sample Testcase :
INPUT
aabbcc
OUTPUT
ccbbaa
Sample Testcase 1:
Input : aa
Output :
aa
Sample Testcase 2:
Input : abc
Output :
cba
Sample Testcase :
INPUT
5
OUTPUT
120
Sample Testcase 1:
Input : 0
Output :
Sample Testcase 2:
Input : 1
Output :
Sample Testcase :
INPUT
423
OUTPUT
324
Sample Testcase 1:
Input : 45
Output :
54
Sample Testcase 2:
Input : 41
Output :
14
4 - Given a string S append a period at the end of the given string (use string stl).
Sample Testcase :
INPUT
vishalrknagar
OUTPUT
vishalrknagar.
Sample Testcase 1:
Input : rk
Output :
rk.
Sample Testcase 2:
Input : kk
Output :
kk.
Sample Testcase :
INPUT
VI
OUTPUT
6
Sample Testcase 1:
Input : X
Output :
10
Sample Testcase 2:
Input : XI
Output :
11
Sample Testcase :
INPUT
aab xxy
OUTPUT
yes
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Input : aa bc
Output :
no
7 - Given a string s swap the even and odd characters.
Sample Testcase :
INPUT
abcd
OUTPUT
badc
Sample Testcase 1:
Input : baba
Output :
abab
Sample Testcase 2:
Input : aabc
Output :
aacb
Sample Testcase :
INPUT
aab xxy
OUTPUT
Aab Xxy
Sample Testcase 1:
Input : aaa BBB
Output :
Aaa Bbb
Sample Testcase 2:
Input : aa bc
Output :
Aa Bc
9 - Given a range ie 2 numebrs l and r count the number of prime numbers in the range (inclusive of l
and r ).
Input Size : l <= r <= 100000(complexity O(n) read about Sieve of Eratosthenes)
Sample Testcase :
INPUT
25
OUTPUT
Sample Testcase 1:
Input : 5 10
Output :
Sample Testcase 2:
Input : 2 10
Output :
4
10 - Given 2 strings check whether they differ by only one character.
Sample Testcase :
INPUT
aab aay
OUTPUT
yes
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Input : aa bc
Output :
no
SET-2
Sample Testcase :
INPUT
Saturday
Monday
OUTPUT
yes
no
Sample Testcase 1:
Input : Tuesday
Output :
no
Sample Testcase 2:
Input : Sunday
Output :
yes
12 - Given two numbers N,K followed by an array of N elements, print the array after doing right shift K
times.
Sample Testcase :
INPUT
32
723
OUTPUT
237
Sample Testcase 1:
Input : 5 2
12345
Output :
45123
Sample Testcase 2:
Input : 1 12
Output :
Sample Testcase :
INPUT
19
OUTPUT
82
Sample Testcase 1:
Input : 100112
Output :
Sample Testcase 2:
Input : 11
Output :
2
14 - Given a string S of length N, print the reversed string after removing the vowels.
Sample Testcase :
INPUT
Sundar
OUTPUT
rdnS
Sample Testcase 1:
Input : 14
gjkljheiruhjmq
Output :
qmjhrhjlkjg
Sample Testcase 2:
Input : 9
$35% @ $7
Output :
7$ @ %53$
15 - Given a string of length N, print the most repeated letter(It is guarenteed that a single answer is
possible).
Sample Testcase :
INPUT
Vishal Yadav
OUTPUT
a
Sample Testcase 1:
Output :
Sample Testcase 2:
Output :
16 - Given a number N and an array of N integers, every number is repeated except for one. Print that
one number.
Sample Testcase :
INPUT
10
1232332552
OUTPUT
Sample Testcase 1:
Input : 10
1234554322
Output :
Sample Testcase 2:
Input : 9
Output :
234
17 - Given two numbers L,R print the smallest number which is divisible by both L and R.
Sample Testcase :
INPUT
10 130
OUTPUT
130
Sample Testcase 1:
Input : 1 1
Output :
Sample Testcase 2:
Input : 8 99
Output :
792
18 - Given a number N and an array of N strings, find the number of strings that are an anagram of
'kabali'.
INPUT
kabali
kaabli
kababa
kab
kabail
OUTPUT
Sample Testcase 1:
Input : 3
kabail
kabila
aabilk
Output :
Sample Testcase 2:
Input : 1
klibaa
Output :
Sample Testcase :
INPUT
18
OUTPUT
23
Sample Testcase 1:
Input : 50
Output :
25
Sample Testcase 2:
Input : 19
Output :
19
20 - Given a string of length N, print the encoded string by adding 3 to each character(x maps to a,y
maps to b,z maps to c).
Sample Testcase :
INPUT
RADAR
OUTPUT
UDGDU
Sample Testcase 1:
Input : JOK
Output :
MRN
Sample Testcase 2:
Input : ZZZZZ
Output :
CCCCC
SET-3
21 - Given 3 points check whether they can lie on the same line.
Sample Testcase :
INPUT
01
00
02
OUTPUT
yes
Sample Testcase 1:
Input : 1 0
00
20
Output :
yes
Sample Testcase 2:
Input : 0 2
16
2 10
Output :
no
22 - Given a number and a number of K, find the greatest number which divides both.
Sample Testcase :
INPUT
5 10
OUTPUT
Sample Testcase 1:
Input : 30 40
Output :
10
Sample Testcase 2:
Input : 1 1
Output :
23 - Given a number N and K followed by N numbers. Now given K numbers Ki means insert the number
ki in the array and now print the maximum.
Input Size : K <= N <= 10000(read about priority queues and implement)
Sample Testcase :
INPUT
52
12345
54
OUTPUT
55
Sample Testcase 1:
Input : 5 3
10 2 3 5 5
10 20 3
Output :
10 20 20
Sample Testcase 2:
Input : 5 2
12345
56
Output :
56
Sample Testcase :
INPUT
1a
OUTPUT
no
Sample Testcase 1:
Input : 1shdbshabdsa
Output :
no
Sample Testcase 2:
Input : 122132132323213
Output :
yes
Sample Testcase :
INPUT
aac ab aa
OUTPUT
aa ab aac
Sample Testcase 1:
Input : 3
aac ab aaaaaaaaaaaaaaa
Output :
ab aac aaaaaaaaaaaaaaa
Sample Testcase 2:
Input : 1
aa
Output :
aa
Sample Testcase :
INPUT
aab xxy
OUTPUT
aab xxy
Sample Testcase 1:
Output :
aaaBBB
Sample Testcase 2:
Input : a a v
Output :
aav
27 - Given a string change upper case to lower case and lower case to upper case.
Sample Testcase :
INPUT
abcD
OUTPUT
ABCd
Sample Testcase 1:
Input : baba
Output :
BABA
Sample Testcase 2:
Input : AabC
Output :
aABc
Sample Testcase :
INPUT
aab xxy
OUTPUT
aabxxy
Sample Testcase 1:
Output :
AaaBbb
Sample Testcase 2:
Input : aa bc
Output :
aabc
29 - Given a range i.e., 2 numbers l and r count the number of perfect squares in the range (inclussive of
l and r ).
Sample Testcase :
INPUT
25
OUTPUT
Sample Testcase 1:
Input : 5 10
Output :
Sample Testcase 2:
Input : 2 10
Output :
30 - Given 2 strings and a number K, check whether they differ by exactly K characters.
Sample Testcase :
INPUT
aab aay 1
OUTPUT
yes
Sample Testcase 1:
Output :
no
Sample Testcase 2:
Input : aa bc 1
Output :
no
SET-4
Sample Testcase :
INPUT
(())
((((
OUTPUT
yes
no
Sample Testcase 1:
Input : (((()))(
Output :
no
Sample Testcase 2:
Input : ()()()()
Output :
yes
32 - Given 2 numbers N,K followed by a sorted array of N elements, search and tell if an element K is
present.
Sample Testcase :
INPUT
32
237
OUTPUT
Yes
Sample Testcase 1:
Input : 5 2
12345
Output :
Yes
Sample Testcase 2:
Input : 1 12
Output :
No
33 - Given a number N, and a N*N matrix containing only 0's and 1's, where 0's represent water and 1's
representing land, find the number of island 1's(1 surrounded by 0 on all 4 sides). Assume that all 4
edges of the matrix is surrounded by water.
Sample Testcase :
INPUT
110
000
010
OUTPUT
Sample Testcase 1:
Input : 1
Output :
Sample Testcase 2:
Input : 3
101
010
101
Output :
5
34 - Given a string S of length N, print every 3rd character starting from 0th index.
Sample Testcase :
INPUT
Sundar
OUTPUT
Sd
Sample Testcase 1:
Input : 2
Output :
Sample Testcase 2:
Input : 3Afgdwxtrer
Output :
3gxe
35 - Given a string of length N, print the least repeated letter in each word(It is guarenteed that a single
answer is possible).
Sample Testcase :
INPUT
OUTPUT
ishlyer
Sample Testcase 1:
Output :
93
Sample Testcase 2:
Output :
wby
Sample Testcase :
INPUT
10 0
OUTPUT
Sample Testcase 1:
Input : 10805643 2
Output :
Sample Testcase 2:
Input : 4444444444 4
Output :
10
37 - Vishal is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off
from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He
has noticed that in this way it's impossible to get from some snow drifts to some other by any sequence
of moves. He now wants to heap up some additional snow drifts, so that he can get from any snow drift
to any other one. He asked you to find the minimal number of snow drifts that need to be created. We
assume that Vishal can only heap up snow drifts at integer coordinates. The first line of input contains a
single integer N the number of snow drifts. Each of the following n lines contains two integers xi and yi
the coordinates of the i-th snow drift. Note that the north direction coinсides with the direction of Oy
axis, so the east direction coinсides with the direction of the Ox axis. All snow drift's locations are
distinct.
Sample Testcase :
INPUT
21
12
OUTPUT
Sample Testcase 1:
Input : 9
811 859
656 676
76 141
945 951
497 455
18 55
335 294
267 275
656 689
Output :
Sample Testcase 2:
Input : 6
535 699
217 337
508 780
180 292
393 112
732 888
Output :
Sample Testcase :
INPUT
OUTPUT
248
Sample Testcase 1:
Input : 40
Output :
2 4 10 20 40
Sample Testcase 2:
Input : 10
Output :
2 10
Sample Testcase :
INPUT
64
OUTPUT
yes
Sample Testcase 1:
Input : 222
Output :
no
Sample Testcase 2:
Input : 1
Output :
yes
40 - Given a number N, how many ways you can make N using 1's and 2's only.
Sample Testcase :
INPUT
10
OUTPUT
Sample Testcase 1:
Input : 2
Output :
Sample Testcase 2:
Input : 5
Output :
SET-5
Sample Testcase :
INPUT
64 8
OUTPUT
yes
Sample Testcase 1:
Input : 868 7
Output :
no
Sample Testcase 2:
Input : 1024 2
Output :
yes
Sample Testcase :
INPUT
237
OUTPUT
yes
Sample Testcase 1:
Input : 5
12345
Output :
yes
Sample Testcase 2:
Input : 1
Output :
yes
43 - Given 2 strings of length N,M check if the second string is a substring of the first string.
Sample Testcase :
INPUT
Banana ana
OUTPUT
yes
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Output :
no
44 - Given a string S of length N and a number K, print the string obtained by rotating the orignal string
by K positions.
Sample Testcase :
INPUT
Sundar 3
OUTPUT
darSun
Sample Testcase 1:
Input : ggggg 100
Output :
ggggg
Sample Testcase 2:
Input : 3Afg 1
Output :
g3Af
45 - Given 2 numbers P,A which are the perimeter and area of a rectangle respectively, find if there can
actually be a rectangle with this perimeter and area having integer sides.
Sample Testcase :
INPUT
20 25
OUTPUT
yes
Sample Testcase 1:
Input : 12 8
Output :
yes
Sample Testcase 2:
Input : 1 12
Output :
no
46 - Given an angle A, print the sine of the angle.
Sample Testcase :
INPUT
30
OUTPUT
0.5
Sample Testcase 1:
Input : 720
Output :
Sample Testcase 2:
Input : 270
Output :
-1
Sample Testcase :
INPUT
2 2 176
OUTPUT
yes
Sample Testcase 1:
Input : 9 0 171
Output :
no
Sample Testcase 2:
Input : 12 12 156
Output :
yes
Sample Testcase :
INPUT
OUTPUT
13
Sample Testcase 1:
Input : 41
Output :
1 41
Sample Testcase 2:
Input : 10
Output :
125
Sample Testcase :
INPUT
999
OUTPUT
INT
Sample Testcase 1:
Input : 222
Output :
INT
Sample Testcase 2:
Input : -2,147,483,648
Output :
INT
50 - Given a number N, check if N is divisible by any number less than N other than 1.
Sample Testcase :
INPUT
10
OUTPUT
yes
Sample Testcase 1:
Input : 2
Output :
yes
Sample Testcase 2:
Input : 5
Output :
yes
SET-6
Sample Testcase :
INPUT
12345
OUTPUT
Sample Testcase 1:
Input : 5
11115
Output :
Sample Testcase 2:
Input : 5
32345
Output :
52 - Given 2 numbers N and K followed by N numbers, find the kth smallest element.
Sample Testcase :
INPUT
52
12345
OUTPUT
Sample Testcase 1:
Input : 5 4
11115
Output :
Sample Testcase 2:
Input : 5 5
32345
Output :
Sample Testcase :
INPUT
aabbcc
OUTPUT
Sample Testcase 1:
Input : 4
Output :
Sample Testcase 2:
Input : sdsadsad
Output :
54 - Given 2 string S, check whether they are same without using strcmp(case sensitive).
Sample Testcase :
INPUT
rknagar rknagar
OUTPUT
yes
Sample Testcase 1:
Input : rk Rk
Output :
no
Sample Testcase 2:
Input : kk k
Output :
no
55 - Given 2 string S, check whether they are same without using strcmp(case insensitive).
Sample Testcase :
INPUT
rknagar Rknagar
OUTPUT
yes
Sample Testcase 1:
Input : rk Rk
Output :
yes
Sample Testcase 2:
Input : kk k
Output :
no
56 - Given a string and a character K, find at what position the character K occurs for the first time.
Sample Testcase :
INPUT
aab b
OUTPUT
3
Sample Testcase 1:
Input : aaa a
Output :
Sample Testcase 2:
Input : aabc b
Output :
57 - Given a string and a character K, find how many times the character repeats.
Sample Testcase :
INPUT
aab b
OUTPUT
Sample Testcase 1:
Input : aaa a
Output :
Sample Testcase 2:
Input : aabc b
Output :
1
58 - Given a sentence and a string S, find how many times the word occurs.
Sample Testcase :
INPUT
xxy
OUTPUT
Sample Testcase 1:
aaa
Output :
Sample Testcase 2:
Input : aa bc Aaa
bb
Output :
59 - Given a number N followed by N numbers if there is a number '0' occuring print all the numbers
given before 0 and till the previously occuring 0(if the are no numbers between 2 0's don't print
anything but given there will be atleast one output(ie atleast one answer possible)).
Sample Testcase :
INPUT
10
1110101101
OUTPUT
111111
Sample Testcase 1:
Input : 3
101
Output :
Sample Testcase 2:
Input : 4
1011
Output :
Sample Testcase :
INPUT
aab aay
OUTPUT
yes
Sample Testcase 1:
yes
Sample Testcase 2:
Input : aa bc
Output :
no
SET-7
61 - Given 2 numbers N,X and an array of N integers, check if there exists 2 numbers in the array with
sum equal to X.
Sample Testcase :
INPUT
24
22
OUTPUT
yes
Sample Testcase 1:
Input : 2 2
20
Output :
no
Sample Testcase 2:
Input : 10 0
0123456780
Output :
yes
62 - Given number N, find the minimum integer by which the number must be divided so that the result
is an odd number.
Sample Testcase :
INPUT
OUTPUT
Sample Testcase 1:
Input : 14
Output :
Sample Testcase 2:
Input : 220
Output :
63 - Given a number N and 2 arrays A and B of sorted order of size N, print the common elements.
Sample Testcase :
INPUT
11111
12345
OUTPUT
Sample Testcase 1:
Input : 2
12
12
Output :
12
Sample Testcase 2:
Input : 3
148
1 8 16
Output :
18
64 - Given 2 numbers N,K followed by N numbers. Print all the elements lesser than K in sorted order.
Sample Testcase :
INPUT
53
12141
OUTPUT
1112
Sample Testcase 1:
Input : 5 5
12415
Output :
1124
Sample Testcase 2:
Input : 5 3
12435
Output :
12
65 - Given a number N and an array of N numbers, print all elements lesser than N.
Sample Testcase :
INPUT
31 14 15 7 2
OUTPUT
Sample Testcase 1:
Input : 2
71
Output :
1
Sample Testcase 2:
Input : 3
127
Output :
12
66 - Given 2 numbers N,K and an array of N numbers, print the number that has been repeated K
times(guaranteed that an answer exists).
Sample Testcase :
INPUT
52
12402
OUTPUT
Sample Testcase 1:
Input : 5 3
13343
Output :
Sample Testcase 2:
Input : 5 5
11111
Output :
1
67 - Given a number N, find the factorial of that number.
Sample Testcase :
INPUT
OUTPUT
120
Sample Testcase 1:
Input : 2
Output :
Sample Testcase 2:
Input : 3
Output :
68 - Given a number N and an array of N numbers, find the length of the longest repeating sequence of
numbers.
Sample Testcase :
INPUT
12223456
OUTPUT
3
Sample Testcase 1:
Input : 5
55333
Output :
Sample Testcase 2:
Input : 5
-2 -2 -3 -3 5
Output :
69 - Given 2 numbers N,K print the array after deleting the last K elements.
Sample Testcase :
INPUT
52
12345
OUTPUT
123
Sample Testcase 1:
Input : 3 2
123
Output :
1
Sample Testcase 2:
Input : 5 3
11 14 1 2 3
Output :
11 14
SET-8
70 - Given a string S of length N, print the string after appending ' Answer' to the end of the string.
Sample Testcase :
INPUT
GUVI
OUTPUT
GUVI Answer
Sample Testcase 1:
Input : A
Output :
A Answer
Sample Testcase 2:
Input : Fresh
Output :
Fresh Answer
71 - Given a number N followed by N numbers for every 2 consecutive numbers print the maximum of
the 2.
Sample Testcase :
INPUT
12345
OUTPUT
2345
Sample Testcase 1:
Input : 5
11115
Output :
1115
Sample Testcase 2:
Input : 5
32345
Output :
3345
72 - Given an array in which the elements are increasing up to a point and then decreases (this is also
called a bitonic array), find the maximum element.
Sample Testcase :
INPUT
5
12321
OUTPUT
Sample Testcase 1:
Input : 5
11151
Output :
Sample Testcase 2:
Input : 5
33343
Output :
73 - Given a number N,K followed by array of N numbers where the difference between any adjacent
numbers is 1. Find the position of the given number K.
Sample Testcase :
INPUT
51
32123
OUTPUT
Sample Testcase 1:
Input : 7 1
3232321
Output :
Sample Testcase 2:
Input : 5 2
43432
Output :
Sample Testcase :
INPUT
34
OUTPUT
81
Sample Testcase 1:
Input : 3 2
Output :
Sample Testcase 2:
Input : 10 2
Output :
100
75 - Given an array A of distinct numbers, count the number of pairs (i,j) such that A[i] < A[j].
Sample Testcase :
INPUT
12345
OUTPUT
10
Sample Testcase 1:
Input : 5
11115
Output :
Sample Testcase 2:
Input : 3
123
Output :
76 - Given an array of numbers which contains all even numbers except one, or all add numbers except
one. Find the different number?
Sample Testcase :
INPUT
13457
OUTPUT
Sample Testcase 1:
Input : 5
13578
Output :
Sample Testcase 2:
Input : 5
02458
Output :
77 - Given an array of numbers, find the maximum length of increasing (non-decreasing) continuous
sub-array?
Sample Testcase :
INPUT
12321
OUTPUT
Sample Testcase 1:
Input : 7
12323578
Output :
Sample Testcase 2:
Input : 7
12328671
Output :
Sample Testcase :
INPUT
54
12345
1234
OUTPUT
112233445
Sample Testcase 1:
Input : 5 3
12345
123
Output :
11223345
Sample Testcase 2:
Input : 5 3
55555
123
Output :
12355555
79 - Given an array, find the maximum difference between any two elements in that array?
Sample Testcase :
INPUT
12345
OUTPUT
Sample Testcase 1:
Input : 5
32335
Output :
Sample Testcase 2:
Input : 5
32343
Output :
80 - Given an array, find the minimum difference between any two elements in that array?
Input Size : N <= 1000000(complexity O(n) or O(nlogn))
Sample Testcase :
INPUT
12345
OUTPUT
Sample Testcase 1:
Input : 5
32335
Output :
Sample Testcase 2:
Input : 5
32343
Output :
SET-9
81 - Given a number N and an array of N integers, find the maximum of Bitwise AND of all segments.
Sample Testcase :
INPUT
2
24
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 10
1234556789
Output :
82 - Given a number N and an array of N integers, find the Bitwise AND of the array.
Sample Testcase :
INPUT
24
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 1
Output :
83 - Given a number N and an array of N integers, find the Bitwise OR of the array.
Sample Testcase :
INPUT
24
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 1
Output :
9
84 - Given a number N and an array of N integers, find the maximum of Bitwise OR of all segments.
Sample Testcase :
INPUT
24
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 1
Output :
Sample Testcase :
INPUT
5
OUTPUT
-6
Sample Testcase 1:
Input : 100
Output :
-101
Sample Testcase 2:
Input : 3456
Output :
-3457
86 - Given a number N and an array of N integers, find the Bitwise XOR of the array.
Sample Testcase :
INPUT
24
OUTPUT
Sample Testcase 1:
Input : 2 2
Output :
Sample Testcase 2:
Input : 1
Output :
87 - Given 2 numbers N,K print the number after performing left shift 'K' times.
Sample Testcase :
INPUT
52
OUTPUT
20
Sample Testcase 1:
Input : 5 20
Output :
5242880
Sample Testcase 2:
Input : 3 45
Output :
24576
88 - Given 2 numbers N,K print the number after performing right shift 'K' times(upto 2 decimal places).
Sample Testcase :
INPUT
52
OUTPUT
Sample Testcase 1:
Input : 5 1
Output :
Sample Testcase 2:
Input : 300 2
Output :
75.00
Sample Testcase :
INPUT
52
OUTPUT
20
Sample Testcase 1:
Input : 3 1
Output :
Sample Testcase 2:
Input : 3 2
Output :
Sample Testcase :
INPUT
52
OUTPUT
10
Sample Testcase 1:
Input : 3 0
Output :
Sample Testcase 2:
Input : 3 2
Output :
SET-10
Sample Testcase :
INPUT
OUTPUT
101
Sample Testcase 1:
Input : 8
Output :
1000
Sample Testcase 2:
Input : 3472
Output :
110110010000
Sample Testcase :
INPUT
101
OUTPUT
Sample Testcase 1:
Input : 1001
Output :
9
Sample Testcase 2:
Input : 110110010000
Output :
3472
Sample Testcase :
INPUT
32123
OUTPUT
23213
Sample Testcase 1:
Input : 7
3232321
Output :
2323231
Sample Testcase 2:
Input : 5
43432
Output :
34342
94 - Given a number N, check whether it has repeating digits.
Sample Testcase :
INPUT
11234
OUTPUT
yes
Sample Testcase 1:
Input : 1
Output :
no
Sample Testcase 2:
Input : 1234563567824
Output :
yes
95 - Given a number N, print the kth digit from the given position p(given order N P K).
Sample Testcase :
INPUT
5765 2 1
OUTPUT
Sample Testcase 1:
Input : 5111233 3 2
Output :
2
Sample Testcase 2:
Input : 3123 2 1
Output :
Sample Testcase :
INPUT
51233
OUTPUT
Sample Testcase 1:
Input : 242343
Output :
Sample Testcase 2:
Input : 34324234324
Output :
97 - Given a range[l,r], print the sum of all the odd numbers in the range(inclusive).
Sample Testcase:
INPUT
5 10
OUTPUT
21
Sample Testcase 1:
Input : 7 11
Output :
27
Sample Testcase 2:
Input : 7 13
Output :
40
97 - Given a range[l,r], print the sum of all the odd numbers in the range(inclusive).
Sample Testcase:
INPUT
5 10
OUTPUT
21
Sample Testcase 1:
Input : 7 11
Output :
27
Sample Testcase 2:
Input : 7 13
Output :
40
98 - Given a number N and a number K, check if it has all digits from 0 to k in it(take input as string).
Sample Testcase :
INPUT
1234034 4
OUTPUT
yes
Sample Testcase 1:
Input : 545321340468 6
Output :
yes
Sample Testcase 2:
Input : 564565456120 6
Output :
no
Sample Testcase :
INPUT
1100100
OUTPUT
144
Sample Testcase 1:
Input : 101111000
Output :
570
Sample Testcase 2:
Input : 1011110
Output :
136
Sample Testcase :
INPUT
1100100
OUTPUT
64
Sample Testcase 1:
Input : 101111000
Output :
178
Sample Testcase 2:
Input : 1011110
Output :
5E
101 - Given a number N and an array of N integers, find the sum of the maximum elements obtained by
considering all consecutive pairs of adjacent elements.
Sample Testcase :
INPUT
12345
OUTPUT
14(2+3+4+5)
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 10
1234556789
Output :
49
102 - Given a number N and an array of N integers, find the maximum sum of the maximum elements
obtained by considering all consecutive pairs of adjacent elements after rearranging the array suitably.
Sample Testcase :
INPUT
12345
OUTPUT
18
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 3
123
Output :
103 - Given a number N and an array of N integers, find the minimum sum of the maximum elements
obtained by considering all consecutive pairs of adjacent elements after rearranging the array suitably.
Sample Testcase :
INPUT
12345
OUTPUT
18
Sample Testcase 1:
Input : 2
22
Output :
2
Sample Testcase 2:
Input : 3
123
Output :
104 - Given a number N and an array of N integers, find the sum of the sums obtained by considering all
consecutive pairs of adjacent elements.
Sample Testcase :
INPUT
12345
OUTPUT
24((1+2)+(2+3)+(3+4)+(4+5))
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 2
12
Output :
3
105 - Given a number N and an array of N integers, sort the array in increasing order and print the
original indices of the elements present in sorted array.
Sample Testcase :
INPUT
54321
OUTPUT
54321
Sample Testcase 1:
Input : 2
25
Output :
12
Sample Testcase 2:
Input : 2
100 99
Output :
21
106 - Given a number N and an array of N integers, print the array after removing duplicate elements.
Sample Testcase :
INPUT
2442
OUTPUT
24
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 1
Output :
Sample Testcase :
INPUT
Happy Birthday
Happy
OUTPUT
Sample Testcase 2:
Input : GUVI
GUVI
Output :
1
108 - Given a number N and an array of N integers, print the prefix sum array.
Sample Testcase :
INPUT
2442
OUTPUT
2 6 10 12
Sample Testcase 1:
Input : 2
22
Output :
24
Sample Testcase 2:
Input : 1
Output :
109 - Given a number N and an array of N integers, print the suffix sum array.
Sample Testcase :
INPUT
2442
OUTPUT
12 8 6 2
Sample Testcase 1:
Input : 2
22
Output :
42
Sample Testcase 2:
Input : 1
Output :
110 - Given 2 numbers N, print the sum of prefix sum and suffix sum array for each position.
Sample Testcase :
INPUT
2442
OUTPUT
14 16 16 14
Sample Testcase 1:
Input : 2
22
Output :
66
Sample Testcase 2:
Input : 1
Output :
111 - Given 2 numbers N and M followed by N numbers and M numbers, print the common numbers in
sorted order.
Sample Testcase :
INPUT
54
123451234
OUTPUT
1234
Sample Testcase 1:
Input : 5 3
11115456
Output :
Sample Testcase 2:
Input : 5 3
32345453
Output :
345
112 - Given an array print the number of subarrays that can be formed with it.
Sample Testcase :
INPUT
12321
OUTPUT
15
Sample Testcase 1:
Input : 3
151
Output :
Sample Testcase 2:
Input : 4
3343
Output :
10
Sample Testcase :
INPUT
01/13/1999
OUTPUT
no
Sample Testcase 1:
Input : 12/2/1999
Output :
no
Sample Testcase 2:
Input : 32/12/12222
Output :
no
Sample Testcase :
INPUT
3 4 1000000007
OUTPUT
81
Sample Testcase 1:
Input : 12 5 1000000007
Output :
248832
Sample Testcase 2:
Input : 1 3 1000000007
Output :
115 - Given 2 strings S and M, check whether they have same number of characters if not make the
longer string shorter to the same size of the smaller one by deleting characters from the end and
concatinate them and print it.
Sample Testcase :
INPUT
rknagar vishal
OUTPUT
rknagavishal
Sample Testcase 1:
Input : rk e
Output :
re
Sample Testcase 2:
Input : k k
Output :
116 - Given an array of numbers find the number of occurences of each character and print it in the
decreasing order of occurences, if 2 or more numbers occur the same number of times, print the
numbers in decreasing order(hint: read about pair STL).
Sample Testcase :
INPUT
33447
OUTPUT
437
Sample Testcase 1:
Input : 5
15518
Output :
518
Sample Testcase 2:
Input : 5
00458
Output :
0854
Sample Testcase :
INPUT
abc
OUTPUT
c-b-a
Sample Testcase 1:
Input : aabc
Output :
c-b-a-a
Sample Testcase 2:
Input : abba
Output :
a-b-b-a
118 - Find the max length-word in a given sentence and return the max-length word. if two words are of
same length return the first occuring word of max-length.
Sample Testcase :
INPUT
Hello world
OUTPUT
Hello
Sample Testcase 1:
Output :
jdnasjdsajdnsajd
Sample Testcase 2:
Output :
asjkbcjaskchas,jkcnsakjc,sna
Sample Testcase :
INPUT
293
OUTPUT
659
Sample Testcase 1:
Input : 57
Output :
87
Sample Testcase 2:
Input : DC88
Output :
56456
120 - Given a number N in decimal, print the length of the corresponding binary digit.
Sample Testcase :
INPUT
10
OUTPUT
Sample Testcase 1:
Input : 0
Output :
Sample Testcase 2:
Input : 23
Output :
5
121 - Given a number N and an array of N strings, find the lexicographically smallest string.
Sample Testcase :
INPUT
code
overload
vishal
sundar
anish
OUTPUT
anish
Sample Testcase 1:
Input : 2
Output :
Sample Testcase 2:
Input : 3
lazy
segtree
prop
Output :
lazy
122 - Given a date(DD-MM-YYYY), print the month in words.
Sample Testcase :
INPUT
01-01-2018
OUTPUT
January
Sample Testcase 1:
Input : 01-11-1890
Output :
November
Sample Testcase 2:
Input : 15-08-1947
Output :
August
123 - Given a number N, print all the prime factors once in ascending order.
Sample Testcase :
INPUT
100
OUTPUT
25
Sample Testcase 1:
Input : 35
Output :
57
Sample Testcase 2:
Input : 12
Output :
23
124 - Given a number N and an array of N integers, find the smallest number divisible by all the
elements of the array.
Sample Testcase :
INPUT
12345
OUTPUT
60
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 2
1 99
Output :
99
125 - Given a number N and an array of N integers, find the greatest number which divides all the
elements of the array.
Sample Testcase :
INPUT
12345
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 2
1 99
Output :
126 - Given 2 numbers N,K and an array of N integers, print all numbers in sorted order if it has been
repeated less than K times.
Sample Testcase :
INPUT
42
2441
OUTPUT
12
Sample Testcase 1:
Input : 2 3
22
Output :
Sample Testcase 2:
Input : 1 4
Output :
Sample Testcase :
INPUT
Happy Birthday
Happy
OUTPUT
Birthday
Sample Testcase 1:
New
Output :
Input : GUVI
GUVI
Output :
128 - Given a number N and an array of N integers, predict if the product of all elements wud be even or
odd(actual multiplication may lead to overflows ai <= 100000000).
Sample Testcase :
INPUT
2442
OUTPUT
even
Sample Testcase 1:
Input : 2
35
Output :
odd
Sample Testcase 2:
Input : 1
Output :
odd
129 - Given a number N and an array of N integers, print the sum of minimum sum sub-array(empty
subbarrays are also taken).
Sample Testcase :
INPUT
2442
OUTPUT
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 1
-9
Output :
-9
130 - Given a number N and array of N integers, print the prefix sum array for each position if it is
divisible by 2 else print the element itself.
Sample Testcase :
INPUT
2442
OUTPUT
2 6 10 12
Sample Testcase 1:
Input : 2
22
Output :
24
Sample Testcase 2:
Input : 1
Output :
131 - A number is given as input. Find the odd digits in the number, add them and find if the sum is odd
or not. If even print E, if odd print O.
Sample Testcase :
INPUT
413
OUTPUT
Sample Testcase 1:
Input : 222226
Output :
E
Sample Testcase 2:
Input : 333
Output :
132 - A number is given as input(as string). Find the maximum length of substring alternating digits of
odd and even.
Sample Testcase :
INPUT
4123
OUTPUT
Sample Testcase 1:
Input : 222226
Output :
Sample Testcase 2:
Input : 3233
Output :
133 - Given 2 numbers n and m, n pairs of numbers a and b are given. In each pair 'a' means a person
can start moving from point 'a' in the x axis to point 'b'(he can visit any point in between). Find if he can
visit point m.
Sample Testcase :
INPUT
35
02
24
35
OUTPUT
yes
Sample Testcase 1:
Input : 1 1
00
Output :
no
Sample Testcase 2:
Input : 1 10
0 10
Output :
yes
134 - Given a number n and 2 numbers l and r followed by n numbers, find the smallest number in the
range [l,r].
Sample Testcase :
INPUT
524
12345
OUTPUT
Sample Testcase 1:
Input : 5 2 5
13225
Output :
Sample Testcase 2:
Input : 5 1 3
13225
Output :
135 - Given array sort it in ascending order till the half of array and in descending order after the half.
Sample Testcase :
INPUT
43124
OUTPUT
34421
Sample Testcase 1:
Input : 1
13
Output :
13
Sample Testcase 2:
Input : 6
431246
Output :
134642
136 - Given an array of numbers and another number k. Find whether K exists and the number of time k
repeats. If it does not exist just print no.
Sample Testcase :
INPUT
53
33447
OUTPUT
yes 2
Sample Testcase 1:
Input : 5 1
11111
Output :
yes 5
Sample Testcase 2:
Input : 5 7
00458
Output :
no
137 - Print the position of first 1 from right to left, in binary representation of an Integer.
Sample Testcase :
INPUT
18
OUTPUT
2
Sample Testcase 1:
Input : 22
Output :
Sample Testcase 2:
Input : 123
Output :
Sample Testcase :
INPUT
2048
OUTPUT
yes
Sample Testcase 1:
Input : 1024
Output :
yes
Sample Testcase 2:
Input : 1
Output :
yes
139 - Given a number N, find the number of ones in its binary representation.
Sample Testcase :
INPUT
276
OUTPUT
Sample Testcase 1:
Input : 2
Output :
Sample Testcase 2:
Input : 24
Output :
140 - Given a string S, check whether it only contains the characters 'a' and 'b'.
Sample Testcase :
INPUT
aabbaa
OUTPUT
yes
Sample Testcase 1:
Input : aabbabsbcbabsbshsbcbcbsucbcsjcbcbsjs
Output :
no
Sample Testcase 2:
Input : aaaaaa
Output :
yes
141 - Given a number N and an array of N strings, find if any 2 consecutive strings have no words in
common.
Sample Testcase :
INPUT
code
overload
vishal
sundar
anish
OUTPUT
yes
Sample Testcase 1:
Input : 2
Output :
yes
Sample Testcase 2:
Input : 3
lazy
segtree
prop
Output :
yes
142 - Given 2 numbers N,K and an array of N strings, find if any K consecutive strings have no words in
common.
Sample Testcase :
INPUT
53
code
overload
vishal
sundar
anish
OUTPUT
yes
Sample Testcase 1:
Input : 2 2
Output :
yes
Sample Testcase 2:
Input : 3 3
lazy
segtree
prop
Output :
yes
143 - Given a number N and 2 arrays of N integers and their weights, sort the array based on their
weights in the ascending order.
Sample Testcase :
INPUT
12345
54321
OUTPUT
54321
Sample Testcase 1:
Input : 3
112
243
Output :
121
Sample Testcase 2:
Input : 1
Output :
2
144 - Given a number N and an array of N integers, print all integers which are divisible by the previous
integer.
Sample Testcase :
INPUT
12365
OUTPUT
16
Sample Testcase 1:
Input : 2
22
Output :
Sample Testcase 2:
Input : 2
1 99
Output :
99
145 - Given a number N and an array of N integers, check if its a permutation of(1-N).
Sample Testcase :
INPUT
5
12345
OUTPUT
yes
Sample Testcase 1:
Input : 2
22
Output :
no
Sample Testcase 2:
Input : 2
1 99
Output :
no
Sample Testcase :
INPUT
42
OUTPUT
12
Sample Testcase 1:
Input : 10 5
Output :
30240
Sample Testcase 2:
Input : 5 3
Output :
20
Sample Testcase :
INPUT
345
OUTPUT
Sample Testcase 1:
Input : 3 4 6
Output :
Sample Testcase 2:
Input : 1 3 6
Output :
148 - Given 2 numbers N,M where N is the number of nodes and M is the number of edges, find if the
resultant graph is a tree.
Sample Testcase :
INPUT
22
12
21
OUTPUT
no
Sample Testcase 1:
Input : 3 3
12
23
32
Output :
no
Sample Testcase 2:
Input : 2 1
12
Output :
yes
149 - Given 2 numbers N,M where N is the number of nodes and M is the number of edges, find if the
resultant graph has cycles.
Sample Testcase :
INPUT
22
12
21
OUTPUT :
yes
Sample Testcase 1:
Input : 3 3
12
23
32
Output :
no
Sample Testcase 2:
Input : 2 1
12
Output :
yes
150 - Given 3 numbers N,M,A where N is the number of nodes and M is the number of edges(weight of
each edge is 1), find the shortest path from node 1 to given node A.
Sample Testcase :
INPUT
222
12
21
OUTPUT
Sample Testcase 1:
Input : 3 3 3
12
23
31
Output :
Sample Testcase 2:
Input : 2 1 1
12
Output :
151.Given a string S, check whether it only contains the characters 'a' and 'b' if
yes print 'yes'. If not check whether one character can be modified to meet the
Sample Testcase :
INPUT
aabbaac
OUTPUT
yes
Sample Testcase 1:
Input :
aabbabsbcbabsbshsbcbcbsucbcsjcbcbsjs
Output :
no
152.Given a string S. Find the maximum length of substring alternating characters of
Sample Testcase :
INPUT
bebibo
OUTPUT
Sample Testcase 1:
Input :
aaaa
Output :
153.Given a string and a number K. Print every kth character from the beginning.
Sample Testcase :
INPUT
string 2
OUTPUT
tig
Sample Testcase 1:
Input :
s1
Output :
154.Given a string and a number K, change every kth character to uppercase from
beginning in string.
Sample Testcase :
INPUT
string 2
OUTPUT
sTrInG
Sample Testcase 1:
Input :
string 6
Output :
strinG
155.Given an array N, sort it in ascending order till it reaches kth elements and
Sample Testcase :
INPUT
52
43124
OUTPUT
34421
Sample Testcase 1:
Input :
11
13
Output :
13
vertices can be partitionedinto 2 sets in such a way, that for each edge (u, v)
that belongs to the graph, u and v belong todifferent sets. You can find more
Consider a tree consisting of n nodes and add edges to it in such a way, that
the graph is stillbipartite. Besides, after adding these edges the graph should
be simple (should’nt contain loops ormultiple edges). What is the maximum number
of edges they can add? A loop is an edge, which connects a node with itself.
Graph doesn't contain multiple edges when foreach pair of nodes there is no more
than one edge between them. A cycle and a loop aren't thesame.
Sample Testcase :
INPUT
12
23
34
45
OUTPUT
Sample Testcase 1:
Input :
23
34
12
45
56
Output :
product of 2 integers.
Sample Testcase :
INPUT
18 2
OUTPUT
Sample Testcase 1:
Input :
22
Output :
3
Sample Testcase :
INPUT
18 2
OUTPUT
Sample Testcase 1:
Input :
32
Output :
159.Given 2 numbers find the number of ones in its binary representation of the product.
Sample Testcase :
INPUT
22
OUTPUT
Sample Testcase 1:
Input :
21
Output :
160.Given 2 numbers, perform bitwise or and find the number of ones in its binary representation.
Sample Testcase :
INPUT
10 5
OUTPUT
Sample Testcase 1:
Input :
21
Output :
SET-17
161 - Given a number N and an array of N strings, find if all strings have atleast one vowel in them.
Sample Testcase :
INPUT
5
code
overload
vishal
sundar
anish
OUTPUT
yes
Sample Testcase 1:
Input : 2
Output :
no
Sample Testcase 2:
Input : 3
lazy
segtree
prop
Output :
yes
162 - Given 2 numbers N,K and an array of N strings, find if atleast K strings have atleast one vowel in
them.
Sample Testcase :
INPUT
53
code
overload
vishal
sundar
anish
OUTPUT
yes
Sample Testcase 1:
Input : 2 2
Output :
no
Sample Testcase 2:
Input : 3 3
lazy
segtree
prop
Output :
yes
163 - Given 2 numbers N,K and an array of N integers, find if the element K exists in the array.
Sample Testcase :
INPUT
52
12345
OUTPUT
yes
Sample Testcase 1:
Input : 3 1
112
Output :
yes
Sample Testcase 2:
Input : 1 1
Output :
no
164 - Given 2 numbers N,K and an array of N integers, print the element K if its exists in the array else
print the element just smaller than K.
Sample Testcase :
INPUT
52
12345
OUTPUT
2
HINT: Read about Lower Bound STL
Sample Testcase 1:
Input : 3 1
112
Output :
Sample Testcase 2:
Input : 1 10
Output :
165 - Given 2 numbers N,K and an array of N integers, print the element in the array which is just greater
than K.
Sample Testcase :
INPUT
52
12345
OUTPUT
Sample Testcase 1:
Input : 3 1
112
Output :
Sample Testcase 2:
Input : 1 1
Output :
Sample Testcase :
INPUT
42
OUTPUT
Sample Testcase 1:
Input : 1023451 5
Output :
120
Sample Testcase 2:
Input : 5 3
Output :
6
167 - Given a string S, print if its length is prime.
Sample Testcase :
INPUT
GUVI
OUTPUT
no
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Output :
no
Sample Testcase :
INPUT
a3b1
OUTPUT
aaab
Sample Testcase 1:
Input : a1
Output :
Sample Testcase 2:
Input : a1b1c1
Output :
abc
Sample Testcase :
INPUT
aaab
OUTPUT
a3b1
Sample Testcase 1:
Input : a
Output :
a1
Sample Testcase 2:
Input : abc
Output :
a1b1c1
170 - Given a string S of length N, print the characters that have been repeated most number of times.
Input Size : N <= 100000
Sample Testcase :
INPUT
OUTPUT
3 eh
Sample Testcase 1:
Input : helloo
Output :
2 lo
Sample Testcase 2:
Output :
2g
SET-18
171 - Given a sentence interchange the words around the word 'and'.
Sample Testcase :
INPUT
OUTPUT
Input : and
Output :
and
Sample Testcase 2:
Input : a a
Output :
aa
172 - A number is given as input. Find the maximum number that can be formed using the digits.
Sample Testcase :
INPUT
4123
OUTPUT
4321
Sample Testcase 1:
Input : 222226
Output :
622222
Sample Testcase 2:
Input : 3233
Output :
3332
173 - Find the difference between the two strings and print the list of words that are missing.
Sample Testcase :
INPUT
this is a string
this a string
OUTPUT
is
Sample Testcase 1:
Input : 110
11
Output :
Sample Testcase 2:
Input : 110
010
Output :
10
174 - Find the difference between the two strings and print the line number and missing strings.
Sample Testcase :
INPUT
this is a string
OUTPUT
1:another
2:is
Sample Testcase 1:
Input : 110
11
Output :
2:0
Sample Testcase 2:
Input : 110
010
Output :
1:0
2:1
175 - write a program which displays whether the given two strings are complementary or not. Assume
both the string contains unique capital alphabets in alphabetical order. Their total length has to be 26. If
we join alphabets of both the strings we should get all capital letters exactly once, then only we can call
them as complementary. Print complementary/non-complementary.
Sample Testcase :
INPUT
ABDCFGIJKLMNOPQUVWXYZ
EHRST
OUTPUT
complementary
Sample Testcase 1:
Input : BDCFGIJKLMNOPQUVWXYZ
EHRST
Output :
non-complementary
Sample Testcase 2:
Input : ABDCFGIJKLMNOPQUEHRSVWXYZ
Output :
complementary
176 - Swagger and Rock are playing a word game. They need to check the two strings use the same base
alphabets. Two strings are said to have same base alphabets if the use the same characters to form the
word. eg: rescue and curse have same base alphabets - c,e,r,s,u.
Sample Testcase :
INPUT
rescue curse
nail snail
OUTPUT
true
Sample Testcase 1:
Output :
true
Sample Testcase 2:
Output :
false
177 - John cena wants to learn alphabet ordering. He was given a task of ordering of alphabets within a
word in a given string. Write a program to help john to order the words.
Sample Testcase :
INPUT
OUTPUT
Sample Testcase 1:
Input : aaa aa
Output :
aaa aa
Sample Testcase 2:
Output :
aabb bbcc
178 - Roman Regins want to write a program that finds the repeated letters and capitalize the common
words. Help him to achieve it.
Sample Testcase :
INPUT
computer program
OUTPUT
cOMPuteR PROgRaM
Sample Testcase 1:
Input : aaa aa
Output :
AAA AA
Sample Testcase 2:
Output :
ABAB BcBc
179 - Given 2 numbers, perform bitwise xor and find the number of ones in its binary representation.
Sample Testcase :
INPUT
10 5
OUTPUT
Sample Testcase 1:
Input : 2 1
Output :
Sample Testcase 2:
Input : 2 4
Output :
2
180 - Given a binary number N, find its nearest power of 2(greater if the number itself is not a power of
2) and print the answer in decimal.
Sample Testcase :
INPUT
101
OUTPUT
Sample Testcase 1:
Input : 11011
Output :
32
Sample Testcase 2:
Input : 11110
Output :
32
SET-19
181 - Given a number N, find if it can be represented as a sum of (3's and 7's).
INPUT
OUTPUT
yes
Sample Testcase 1:
Input : 99
Output :
yes
Sample Testcase 2:
Input : 2
Output :
no
182 - Given a number N(number of boxes) and an array of N box lengths, a box with smaller box length
can be put inside a box with larger box length. Find the minimum number of boxes remaining after all
boxes have been put inside maximally.
Sample Testcase :
INPUT
12334
OUTPUT
2 {(1,2,3),(3,4)}
Sample Testcase 1:
Input : 2
12
Output :
Sample Testcase 2:
Input : 3
123
Output :
183 - Given a number N and an array of N integers, find the number of elements we need to change in
order to convert it into a perumatation.
Sample Testcase :
INPUT
12345
OUTPUT
Sample Testcase 1:
Input : 3
112
Output :
Sample Testcase 2:
Input : 1
2
Output :
184 - Given a number N and an array of N integers, find the number of moves we need to perform in
order to convert it into a perumatation. Each moves invloves increasing or decreasing a single element
by 1.
Sample Testcase :
INPUT
30
OUTPUT
Sample Testcase 1:
Input : 3
112
Output :
Sample Testcase 2:
Input : 1
Output :
1
185 - Given a binary string S of length N, find if its possible to remove some digits in such a way that the
resultant string is the representation of a number divisible by 64.
Sample Testcase :
INPUT
100010001
OUTPUT
yes
Sample Testcase 1:
Input : 1000000
Output :
yes
Sample Testcase 2:
Input : 1010101
Output :
no
186 - Given a string S, find if the strings 'Vishal' and 'Sundar' is present in the string.
Sample Testcase :
INPUT
OUTPUT
yes
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Input : VGPishalSunSS
Output :
no
Sample Testcase :
INPUT
GUVI GREAT
OUTPUT
yes
Sample Testcase 1:
Output :
yes
Sample Testcase 2:
Input : GUVI gr
Output :
no
188 - Given 3 numbers A,B,C find if they can form the sides of a triangle.
Sample Testcase :
INPUT
345
OUTPUT
yes
Sample Testcase 1:
Input : 3 4 6
Output :
yes
Sample Testcase 2:
Input : 1 3 6
Output :
no
189 - Given 3 numbers A,B,C find if they can form the sides of a scalene triangle.
Sample Testcase :
INPUT
345
OUTPUT
yes
Sample Testcase 1:
Input : 3 4 6
Output :
yes
Sample Testcase 2:
Input : 1 3 6
Output :
no
190 - Given 3 numbers A,B,C find if they can form the sides of a right angled triangle.
Sample Testcase :
INPUT
345
OUTPUT
yes
Sample Testcase 1:
Input : 3 4 6
Output :
no
Sample Testcase 2:
Input : 1 3 6
Output :
no
SET-20
191 - Given 2 arrays check if they are mirror images of each other.
Sample Testcase :
INPUT
1234
4321
OUTPUT
yes
Sample Testcase 1:
Input : 2
123
321
Output :
yes
Sample Testcase 2:
Input : 2
12
22
Output :
no
192 - Given an array N, check if the values are alternating between increasing and decreasing.
Sample Testcase :
INPUT
12 14 3 7 4
OUTPUT
yes
Sample Testcase 1:
Input : 5
12 11 3 7 4
Output :
no
Sample Testcase 2:
Input : 5
12121
Output :
yes
193 - Given the values of 'a' and 'b' and one value of 'x' in the equation ax + b = y. Find the value of y.
Sample Testcase :
INPUT
352
OUTPUT
11
Sample Testcase 1:
Input : 1 1 0
Output :
Sample Testcase 2:
Input : 1 10 10
Output :
20
194 - Let P represent Paper, R represent Rock and S represent Scissors. Given 2 out of the 3 determine
which wins(normal rules : p). If its a draw print D.
Sample Testcase :
INPUT
RP
OUTPUT
Sample Testcase 1:
Input : S P
Output :
Sample Testcase 2:
Input : R S
Output :
R
195 - Given a stack of n coins and x players, each player can remove only one coin from the stack for a
move. Find out which player removes the last coin if it starts with player 1.
Sample Testcase :
INPUT
10 4
OUTPUT
Sample Testcase 1:
Input : 10 1
Output :
Sample Testcase 2:
Input : 10 5
Output :
196 - Given a number N and array of N integers, find the number which occurs the least number of
times.
Sample Testcase :
INPUT
33447
OUTPUT
Sample Testcase 1:
Input : 5
11151
Output :
Sample Testcase 2:
Input : 5
00448
Output :
197 - Given a number N and array of N integers, print the difference between the smallest and largest
number.
Sample Testcase :
INPUT
33447
OUTPUT
Sample Testcase 1:
Input : 5
11151
Output :
Sample Testcase 2:
Input : 5
00448
Output :
198 - Given a number N and array of N integers, print the difference between the indices of smallest and
largest number(if there are multiple occurances, consider the first occurance).
Sample Testcase :
INPUT
35447
OUTPUT
Sample Testcase 1:
Input : 5
11151
Output :
Sample Testcase 2:
Input : 5
00448
Output :
4
199 - Given a string S, check if it can be made into a palindrome by making atmost one change.
Sample Testcase :
INPUT
abbx
OUTPUT
yes
Sample Testcase 1:
Input : aa
Output :
yes
Sample Testcase 2:
Input : abc
Output :
no
200 - Given a string S, check whether it has only characters and remove the repeating characters.
Sample Testcase :
INPUT
aabbaa
OUTPUT
ab
Sample Testcase 1:
Input : aabbabsbcbabsbshsbcbcbsucbcsjcbcbsjs
Output :
abschuj
Sample Testcase 2:
Input : aaaaaa
Output :
SET-21
Sample Testcase :
INPUT
OUTPUT
11
Sample Testcase 1:
Input : 9
Output :
Input : 0
Output :
202 - Given a string S of length N, print the vowels first and then consonants in the same order as they
have occurred in the string.
Sample Testcase :
INPUT
asdaqrew
OUTPUT
aaesdqrw
Sample Testcase 1:
Input : funforlife
Output :
uoiefnfrlf
Sample Testcase 2:
Input : qwerty
Output :
eqwrty
203 - Given a number N and an array of N strings, sort the strings based on the number of vowels in
each of the strings in descending order.
Input Size : N <= 1000
Sample Testcase :
INPUT
Vishal
Aaae
Awqr
OUTPUT
Aaae
Vishal
Awqr
Sample Testcase 1:
Input : 3
Freeze
Clone
Zap
Output :
Freeze
Clone
Zap
Sample Testcase 2:
Input : 1
Lalala
Output :
Lalala
204 - Given a number N and an array of N integers, find the sum of all the negative numbers in the array.
Sample Testcase :
INPUT
30
OUTPUT
Sample Testcase 1:
Input : 3
-1 -1 -2
Output :
-4
Sample Testcase 2:
Input : 1
-2
Output :
-2
Sample Testcase :
INPUT
HeLlo
OUTPUT
hElLO
Sample Testcase 1:
Input : JjJjJ
Output :
jJjJj
Sample Testcase 2:
Output :
GooD MOrNING
206 - Given a string S of length N, find if it can be a valid Hexadecimal representation of a number.
Sample Testcase :
INPUT
1AE23
OUTPUT
yes
Sample Testcase 1:
Input : AAB
Output :
yes
Sample Testcase 2:
Input : ABBSA
Output :
no