0% found this document useful (0 votes)
258 views

Player PDF

The document contains descriptions of 30 programming challenges ranging from basic string and number manipulation problems to more complex problems involving arrays, matrices, and algorithms like sorting. The challenges cover a variety of topics like string reversal, factorials, prime numbers, Roman numerals, anagrams, sorting, matrix operations, and pattern matching. The goal of the challenges is to solve them efficiently within the given time and space constraints. Sample test cases and inputs/outputs are provided for each challenge to help understand the problem statement.

Uploaded by

pp aa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views

Player PDF

The document contains descriptions of 30 programming challenges ranging from basic string and number manipulation problems to more complex problems involving arrays, matrices, and algorithms like sorting. The challenges cover a variety of topics like string reversal, factorials, prime numbers, Roman numerals, anagrams, sorting, matrix operations, and pattern matching. The goal of the challenges is to solve them efficiently within the given time and space constraints. Sample test cases and inputs/outputs are provided for each challenge to help understand the problem statement.

Uploaded by

pp aa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 151

PYTHON- PLAYER LEVEL

SET-1

1 - Given a string S, print its reverse.

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

2 - Given a number N, find its factorial.

Input Size : N <= 20

Sample Testcase :

INPUT

5
OUTPUT

120

Sample Testcase 1:

Input : 0

Output :

Sample Testcase 2:

Input : 1

Output :

3 - Given a number N reverse it.

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.

5 - Given a roman number N, convert to integer.

Input Size : N <= 20

Sample Testcase :

INPUT

VI

OUTPUT

6
Sample Testcase 1:

Input : X

Output :

10

Sample Testcase 2:

Input : XI

Output :

11

6 - Given 2 strings, check whether it is isomorphic.

Input Size : |s| <= 100000(complexity O(nlogn))

Sample Testcase :

INPUT

aab xxy

OUTPUT

yes

Sample Testcase 1:

Input : aaa BBB

Output :

yes

Sample Testcase 2:

Input : aa bc

Output :

no
7 - Given a string s swap the even and odd characters.

Input Size : |s| <= 10000000(complexity O(n))

Sample Testcase :

INPUT

abcd

OUTPUT

badc

Sample Testcase 1:

Input : baba

Output :

abab

Sample Testcase 2:

Input : aabc

Output :

aacb

8 - Given a string/sentence change it to camel case.

Input Size : |s| <= 1000000(complexity O(n))

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.

Input Size : |s| <= 100000(complexity O(nlogn) or O(n))

Sample Testcase :

INPUT

aab aay

OUTPUT

yes

Sample Testcase 1:

Input : aaa aaB

Output :

yes

Sample Testcase 2:

Input : aa bc

Output :

no

SET-2

11 - Given a day, print if it is a holiday.

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.

Input Size : 1 <= N, K <= 100000

Sample Testcase :

INPUT

32

723

OUTPUT

237

Sample Testcase 1:

Input : 5 2

12345
Output :

45123

Sample Testcase 2:

Input : 1 12

Output :

13 - Given a number N, print the sum of the squares of its digits.

Input Size : 1 <= N <= 1000000000000000000

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.

Input Size : 1 <= N <= 100000

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).

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

Vishal Yadav

OUTPUT
a

Sample Testcase 1:

Input : 111 2222

Output :

Sample Testcase 2:

Input : xor batttery

Output :

16 - Given a number N and an array of N integers, every number is repeated except for one. Print that
one number.

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

10

1232332552

OUTPUT

Sample Testcase 1:

Input : 10

1234554322

Output :

Sample Testcase 2:
Input : 9

1111 123456789 123456789 123456 123 123 123456 1111 234

Output :

234

17 - Given two numbers L,R print the smallest number which is divisible by both L and R.

Input Size : 1 <= L,R <= 100000

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 Size : 1 <= N <= 1000


Sample Testcase :

INPUT

kabali

kaabli

kababa

kab

kabail

OUTPUT

Sample Testcase 1:

Input : 3

kabail

kabila

aabilk

Output :

Sample Testcase 2:

Input : 1

klibaa

Output :

19 - Given a number N, print its prime factors in sorted order.

Input Size : 2 <= N <= 100000

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).

Input Size : 1 <= N <= 100000

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.

Input Size : N and K <= 100000

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

24 - Validate if a given string is numeric.

Sample Testcase :

INPUT

1a
OUTPUT

no

Sample Testcase 1:

Input : 1shdbshabdsa

Output :

no

Sample Testcase 2:

Input : 122132132323213

Output :

yes

25 - Given an array of N words sort it in ascending order.

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

26 - Given a sentence take out the extra spaces.

Input Size : |s| <= 100000(complexity O(n))

Sample Testcase :

INPUT

aab xxy

OUTPUT

aab xxy

Sample Testcase 1:

Input : aaa BBB

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.

Input Size : |s| <= 10000000(complexity O(n))

Sample Testcase :

INPUT
abcD

OUTPUT

ABCd

Sample Testcase 1:

Input : baba

Output :

BABA

Sample Testcase 2:

Input : AabC

Output :

aABc

28 - Given a string/sentence remove all the spaces.

Input Size : |s| <= 1000000(complexity O(n))

Sample Testcase :

INPUT

aab xxy

OUTPUT

aabxxy

Sample Testcase 1:

Input : Aaa Bbb

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 ).

Input Size : l <= r <= 100000(complexity O(n))

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.

Input Size : |s| <= 100000(complexity O(nlogn) or O(n))

Sample Testcase :

INPUT
aab aay 1

OUTPUT

yes

Sample Testcase 1:

Input : aaa aaB 2

Output :

no

Sample Testcase 2:

Input : aa bc 1

Output :

no

SET-4

31 - Given a string S consisting of only '(' and ')', print if it is balanced.

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.

Input Size : 1 <= N <= 1000000000000000(Do it in logN time complexity)

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.

Input Size : 1 <= N <= 1000

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.

Input Size : 1 <= N <= 100000

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).

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

Vishaal Yadav pradep

OUTPUT

ishlyer
Sample Testcase 1:

Input : 1191 23222

Output :

93

Sample Testcase 2:

Input : xxrewxoooor batttery

Output :

wby

36 - Given 2 numbers N,K print the occurrences of K in N.

Input Size : 1 <= N <= 100000, 0 <= K <= 9

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.

Input Size : 1 <= N,Xi,Yi <= 1000

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 :

38 - Given a number N, print the even factors of the number.

Input Size : 1 <= N <= 1000

Sample Testcase :

INPUT

OUTPUT

248

Sample Testcase 1:

Input : 40

Output :

2 4 10 20 40

Sample Testcase 2:

Input : 10
Output :

2 10

39 - Given a number N, check if it is a power of 2.

Input Size : 1 <= N <= 100000

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.

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

10
OUTPUT

Sample Testcase 1:

Input : 2

Output :

Sample Testcase 2:

Input : 5

Output :

SET-5

41 - Given 2 numbers N,K check if N is a power of K.

Sample Testcase :

INPUT

64 8

OUTPUT

yes

Sample Testcase 1:

Input : 868 7

Output :

no
Sample Testcase 2:

Input : 1024 2

Output :

yes

42 - Given a number N, followed by an array of N elements, check if it is sorted.

Input Size : 1 <= N <= 100000

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.

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

Banana ana

OUTPUT

yes

Sample Testcase 1:

Input : poofle ofle

Output :

yes

Sample Testcase 2:

Input : singintherain imasia

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.

Input Size : 1 <= N, K <= 100000

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.

Input Size : 1 <= P,A <= 100000

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

47 - Given 3 angles A,B,C find if they can be interior angles of a triangle.

Input Size : 0 <= A,B,C <= 180

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

48 - Given a number N, print the odd factors of the number.

Input Size : 1 <= N <= 1000

Sample Testcase :

INPUT

OUTPUT

13

Sample Testcase 1:

Input : 41

Output :

1 41

Sample Testcase 2:

Input : 10

Output :

125

49 - Given a number N, print INT if it is integer range or LONG if it is greater.


Input Size : 1 <= N <= 100000

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.

Input Size : 1 <= N <= 100000

Sample Testcase :

INPUT

10

OUTPUT

yes

Sample Testcase 1:

Input : 2

Output :
yes

Sample Testcase 2:

Input : 5

Output :

yes

SET-6

51 - Given a number N followed by N numbers, find the second smallest element.

Input Size : N <= 100000 (ie do it in O(log n) time complexity)

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

52

12345

OUTPUT

Sample Testcase 1:

Input : 5 4

11115

Output :

Sample Testcase 2:

Input : 5 5

32345

Output :

53 - Given a string S, find its length without using strlen.

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.

Input Size : |s| <= 100000

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.

Input Size : |s| <= 100000

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.

Input Size : |sentence| <= 1000000(complexity O(n)).

Sample Testcase :

INPUT

aab xxy hscbahc

xxy

OUTPUT

Sample Testcase 1:

Input : aaa BBB AAA

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)).

Input Size : 1 < N <= 100000(complexity O(n))

Sample Testcase :
INPUT

10

1110101101

OUTPUT

111111

Sample Testcase 1:

Input : 3

101

Output :

Sample Testcase 2:

Input : 4

1011

Output :

60 - Given 2 strings, check whether they have any common characters.

Input Size : |s| <= 100000(O(n))

Sample Testcase :

INPUT

aab aay

OUTPUT

yes

Sample Testcase 1:

Input : aaa aaB


Output :

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.

Input Size : N,X <= 100000

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.

Input Size : N <= 100000

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.

Input Size : 1 <= N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : 1 <= N <= 10000

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).

Input Size : N,K <= 100000

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.

Input Size : 1 <= N <= 25

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.

Input Size : N <= 100000

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.

Input Size : N,K <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000 (ie do it in O(n) time complexity)

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.

Input Size : N <= 100000

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 :

74 - Given numbers A,B find a^b.

Input Size : 1 <= A <= 5 <= B <= 50

Sample Testcase :

INPUT

34

OUTPUT

81

HINT:- Read about Modular Exponentation

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?

Input Size : |N| <= 100000

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?

Input Size : N <= 100000

Sample Testcase :

INPUT

12321

OUTPUT

Sample Testcase 1:

Input : 7

12323578
Output :

Sample Testcase 2:

Input : 7

12328671

Output :

78 - Given 2 arrays of sizes N and M merge them in sorted order.

Input Size : |s| <= 100000( O(n))

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?

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 :

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.

Input Size N <= 100000

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.

Input Size N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

24

OUTPUT

Sample Testcase 1:

Input : 2

22

Output :

Sample Testcase 2:

Input : 1

Output :

85 - Given a number N, print the Bitwise NOT of the number.

Input Size : 1 <= N <= 10000

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.

Input Size : N <= 100000

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.

Input Size : 1 <= N, K <= 1000

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).

Input Size : 1 <= N, K <= 1000

Sample Testcase :
INPUT

52

OUTPUT

Sample Testcase 1:

Input : 5 1

Output :

Sample Testcase 2:

Input : 300 2

Output :

75.00

89 - Given 2 numbers N,K print the value of nPk(P-Permutation).

Input Size : K <= N <= 10

Sample Testcase :

INPUT

52

OUTPUT

20

Sample Testcase 1:

Input : 3 1

Output :

Sample Testcase 2:
Input : 3 2

Output :

90 - Given 2 numbers N,K print the value of nCk(C-Combination).

Input Size : K <= N <= 10

Sample Testcase :

INPUT

52

OUTPUT

10

Sample Testcase 1:

Input : 3 0

Output :

Sample Testcase 2:

Input : 3 2

Output :

SET-10

91 - Given a number N in decimal convert it to binary.


Input Size : N <= 100000

Sample Testcase :

INPUT

OUTPUT

101

Sample Testcase 1:

Input : 8

Output :

1000

Sample Testcase 2:

Input : 3472

Output :

110110010000

92 - Given a number N in binary convert it to decimal.

Input Size : N <= 100000

Sample Testcase :

INPUT

101

OUTPUT

Sample Testcase 1:

Input : 1001

Output :
9

Sample Testcase 2:

Input : 110110010000

Output :

3472

93 - Given an array of numbers switch(swap) the adjacent characters.

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 :

96 - Given a number N, print the sum of first and last digit.

Input Size : |N| <= 1000000000000000

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).

Input Size : N <= 1000000000000000

Sample Testcase :

INPUT

1234034 4

OUTPUT

yes

Sample Testcase 1:

Input : 545321340468 6

Output :

yes

Sample Testcase 2:

Input : 564565456120 6

Output :

no

99 - Given a binary number convert it to octal.

Sample Testcase :

INPUT

1100100

OUTPUT

144
Sample Testcase 1:

Input : 101111000

Output :

570

Sample Testcase 2:

Input : 1011110

Output :

136

100 - Given a binary number convert it to hexadecimal.

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

54321

OUTPUT

54321

HINT: Read about pair STL

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

2442
OUTPUT

24

HINT:Read about Set STL

Sample Testcase 1:

Input : 2

22

Output :

Sample Testcase 2:

Input : 1

Output :

107 - Given 2 strings S,X print the word position of X in S.

Input Size : 1 <= |s|, |x| <= 1000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 10000

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.

Input Size : N,M <= 100000 (ie do it in O(n) time complexity)

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

12321

OUTPUT

15

Sample Testcase 1:

Input : 3

151

Output :

Sample Testcase 2:

Input : 4

3343

Output :

10

113 - Accept a string and find if it is of date format 'dd/mm/yyyy'.

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

114 - Given 3 numbers A,B,C find (a^b)%c.

Input Size : A,B,C <= 1000000000

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).

Input Size : |N| <= 100000

Sample Testcase :

INPUT

33447
OUTPUT

437

Sample Testcase 1:

Input : 5

15518

Output :

518

Sample Testcase 2:

Input : 5

00458

Output :

0854

117 - Get a input string, reverse it and parse it with '-'.

Input Size : |S| <= 100000

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.

Input Size : |s| <= 100000

Sample Testcase :

INPUT

Hello world

OUTPUT

Hello

Sample Testcase 1:

Input : jdnasjdsajdnsajd sjs sjs sdjdjsnd

Output :

jdnasjdsajdnsajd

Sample Testcase 2:

Input : asjkbcjaskchas,jkcnsakjc,sna sadsd

Output :

asjkbcjaskchas,jkcnsakjc,sna

119 - Given a hexadecimal number convert it to decimal.

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.

Input Size : 1 <= N <= 100000

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.

Input Size : N <= 1000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N,K <= 100000

Sample Testcase :

INPUT

42

2441
OUTPUT

12

Sample Testcase 1:

Input : 2 3

22

Output :

Sample Testcase 2:

Input : 1 4

Output :

127 - Given 2 strings S,X. Print the string after deleting X.

Input Size : 1 <= |s|, |x| <= 1000

Sample Testcase :

INPUT

Happy Birthday

Happy

OUTPUT

Birthday

Sample Testcase 1:

Input : Merry Christmas and Happy New Year

New

Output :

Merry Christmas and Happy Year


Sample Testcase 2:

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).

Input Size : N <= 100000

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).

Input Size : N <= 100000

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.

Input Size : N <= 10000

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.

Input Size : N <= 10000000000

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.

Input Size : N <= 10000000000

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.

Input Size : N <= 100000

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.

Input Size : |N| <= 1000000

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 :

138 - Given a number N, check whether it is a power of 2.

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'.

Input Size : |S| <= 100000

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.

Input Size : N <= 1000

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.

Input Size : K <= N <= 1000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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).

Input Size : N <= 100000

Sample Testcase :

INPUT

5
12345

OUTPUT

yes

Sample Testcase 1:

Input : 2

22

Output :

no

Sample Testcase 2:

Input : 2

1 99

Output :

no

146 - Given 2 numbers A,B. print the value of a!/b!.

Input Size : A,B <= 10000 and A-B <= 5

Sample Testcase :

INPUT

42

OUTPUT

12

Sample Testcase 1:

Input : 10 5

Output :

30240
Sample Testcase 2:

Input : 5 3

Output :

20

147 - Given 3 numbers A,B,C print the result of (a^b)%c.

Input Size : A,B,C <= 100000

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.

Input Size : M,N <= 100000

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.

Input Size : M,N <= 100000

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.

Input Size : M,N <= 100000

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

condition, if yes print 'yes' else print 'no'.

Input Size : |S| <= 100000

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

vowel and consonants.

Input Size : |S| <= 1000000

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

after that sort it in descending order.

Input Size : N <= 100000

Sample Testcase :

INPUT

52
43124

OUTPUT

34421

Sample Testcase 1:

Input :

11

13

Output :

13

156.A tree is a connected acyclic graph. A bipartite graph is a graph, whose

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

formal definitions of a tree and a bipartite graph in the notessection below.

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.

Input Size : |N| <= 1000000

Sample Testcase :

INPUT

12

23
34

45

OUTPUT

Sample Testcase 1:

Input :

23

34

12

45

56

Output :

157.Print the position of first 1 from right to left, in binary representation of

product of 2 integers.

Sample Testcase :

INPUT

18 2

OUTPUT

Sample Testcase 1:

Input :

22

Output :
3

158.Print the position of first 1 from left to right, in binary representation of

product of 2 integers after the first one.

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.

Input Size : N <= 1000

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.

Input Size : K <= N <= 1000

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.

Input Size : N <= 100000

Sample Testcase :
INPUT

52

12345

OUTPUT

yes

HINT: Read about Binary Search

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

52

12345

OUTPUT

HINT: Read about Upper Bound STL

Sample Testcase 1:

Input : 3 1

112
Output :

Sample Testcase 2:

Input : 1 1

Output :

166 - Given 2 numbers A,B. Print the GCD of a!,b!.

Input Size : B <= 10 <= A <= 1000000000

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.

Input Size : 1 <= |s| <= 100000

Sample Testcase :

INPUT

GUVI

OUTPUT

no

Sample Testcase 1:

Input : Merry New Christmas

Output :

yes

Sample Testcase 2:

Input : GUVI great

Output :

no

168 - Given a run-length encoded string, print the expanded output.

Input Size : N <= 100000

Sample Testcase :

INPUT

a3b1

OUTPUT

aaab

Sample Testcase 1:

Input : a1
Output :

Sample Testcase 2:

Input : a1b1c1

Output :

abc

169 - Given a string, print the run-length encoded output.

Input Size : N <= 100000

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

GUVI Geek Techhh

OUTPUT

3 eh

Sample Testcase 1:

Input : helloo

Output :

2 lo

Sample Testcase 2:

Input : gustavo fring

Output :

2g

SET-18

171 - Given a sentence interchange the words around the word 'and'.

Input Size : |S| <= 1000000

Sample Testcase :

INPUT

jack and jill went up and down to get water

OUTPUT

jill and jack went down and up to get water


Sample Testcase 1:

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.

Input Size : N <= 10000000

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

this a another 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.

Input Size : |S| <= 1000000

Sample Testcase :

INPUT

rescue curse

nail snail

OUTPUT

true

Sample Testcase 1:

Input : aaa aaa

Output :

true

Sample Testcase 2:

Input : asas asxsadasca

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

THE PRICE OF BREAD IS 100 RS

OUTPUT

EHT CEIPR FO ABDER IS 001 RS

Sample Testcase 1:

Input : aaa aa

Output :

aaa aa

Sample Testcase 2:

Input : abab bcbc

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:

Input : abab bcbc

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 Size : N <= 100


Sample Testcase :

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.

Input Size : N <= 10000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100

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.

Input Size : 1 <= 100

Sample Testcase :

INPUT

Vishal_Sundar prepared this question

OUTPUT

yes
Sample Testcase 1:

Input : VishalSundar are 2 humans!

Output :

yes

Sample Testcase 2:

Input : VGPishalSunSS

Output :

no

187 - Given 2 strings S,X. Print if their lengths are co-prime.

Input Size : 1 <= |s|, |x| <= 100000

Sample Testcase :

INPUT

GUVI GREAT

OUTPUT

yes

Sample Testcase 1:

Input : Merrynew Christmas

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.

Input Size : A,B,C <= 100000

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.

Input Size : A,B,C <= 100000

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.

Input Size : A,B,C <= 100000

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.

Input Size : N <= 1000000

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.

Input Size : N <= 100000

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.

Input Size : N <= 100000

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.

Input Size : |N| <= 1000000

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.

Input Size : |N| <= 1000000

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).

Input Size : |N| <= 1000000

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.

Input Size : |S| <= 100000

Sample Testcase :

INPUT

aabbaa

OUTPUT

ab

Sample Testcase 1:
Input : aabbabsbcbabsbshsbcbcbsucbcsjcbcbsjs

Output :

abschuj

Sample Testcase 2:

Input : aaaaaa

Output :

SET-21

201 - Given a number N, print the first N Catalan numbers.

Input Size : N <= 100

Sample Testcase :

INPUT

OUTPUT

11

Sample Testcase 1:

Input : 9

Output :

1 1 2 5 14 42 132 429 1430 4862


Sample Testcase 2:

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.

Input Size : N <= 10000

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.

Input Size : N <= 100000

Sample Testcase :

INPUT

30

OUTPUT

Sample Testcase 1:

Input : 3

-1 -1 -2

Output :

-4

Sample Testcase 2:

Input : 1

-2

Output :

-2

205 - Given a string S of length N, reverse the case of each letter.

Input Size : N <= 100

Sample Testcase :

INPUT

HeLlo

OUTPUT

hElLO
Sample Testcase 1:

Input : JjJjJ

Output :

jJjJj

Sample Testcase 2:

Input : gOOd moRning

Output :

GooD MOrNING

206 - Given a string S of length N, find if it can be a valid Hexadecimal representation of a number.

Input Size : N <= 10000

Sample Testcase :

INPUT

1AE23

OUTPUT

yes

Sample Testcase 1:

Input : AAB

Output :

yes

Sample Testcase 2:

Input : ABBSA

Output :

no

You might also like