INFOSYS Online Assessment 1st round - 08/08/21 [On-Campus]
Anonymous User
2536

Problem #1:

You're given string S consisting of 0's and 1's,
it's ugliness value equals to its decimal conversion
u have to minimize it's ugliness if u are given CASH
and u are only allowed to do following operations:

  1. swap any two char with cost A
  2. flip any char with cost B
findSmallest(int N, string S, int CASH, int A, int B);

Return the no of operations needed to this? (ans % mod)

input:
9
111100111
7
2
1
output:
7

Problem #2:

Given strength S of boxes, u can throw a ball into any box,
when u throw a ball into box i two things happen:

  1. the ball jumps to (i + S[i])
  2. Strength of box S[i] decreases by 1
minBalls(int N, vector<int> S);

Return minimum no of balls u have to throw to make strength of
all boxes equal to 1? (ans % mod)

input:
2
2 3
output:
3

Problem #3:

Given a binary tree, return no of ways u can paint the nodes with
only 2 colors W & B, such that distance between each B is atleast K.
(ans % mod)

totalWays(int N, vector<int> parent, int K);

All nodes should colored either W or B.

input:
5
-1 0 0 1 1
2
output:
14

[This was way out of my league:/]
Coding platform was really one of the best: InfyTQ

Comments (4)