CRED OA | 2022 | SDE 2 | Bangalore
Anonymous User
1761

Question 1:

Given an array of integers, determine the number of moves to make all elements equal. Each move consists of choosing all but 1 element and incrementing their values by 1.

Problem: https://leetcode.com/problems/minimum-moves-to-equal-array-elements/

Question 2:

You are a lift manager of apartment, everyone wants to go to top floor from ground floor via lift. Lift is superfast so it takes just 1 second to reach top floor from ground floor.

You need to send people from ground floor to top floor , weight of person is . Also you cannot take more than seconds to send all people from ground floor to top floor.

elevator cost is maximum weight that it can carry in a single trip.

You can transfer any number of people given that total weight of all people in that lift doesn't exceed the maximum weight.

Find the minimum cost so that you can finish the process at max seconds.

Note that you have to send people in the same order that you are given, (i.e You can't send person no. 3 before sending person 2)

Sample Input:

4 3
1 4 7 5

Sample Output:

7

Explanation:
On trip 1 we can carry person1 and 2 (total weight = 1+4 = 5) , on trip 2 we can carry person 3 (total weight = 7) , on trip 3 we can carry person 4(total weight = 5), so answer is 7.

Question 3:
Now with RBI mandating tokenization, CRED has been working on supporting tokenization at our end. But with a bunch of these tokens being stored, the analytics team, quite bored, seems to want to determine something. Given a list of tokens A1…AN, and a series of characters B1…BM, how many pairs can be formed from A, such that the pair of tokens together contains all characters in B.

Each character in B is unique

Sample Input:

3 5
ab1
hyap1
bba2
zxc2oi
aa1bfd
iouy1

Sample Output:

6

Explanation:
6 valid pairs can be formed:

(hyap1, bba2) 
(hyap1, aa1bfd) 
(bba2, aa1bfd) 
(bba2, iouy1) 
(zxc2oi, aa1bfd) 
(aa1bfd, iouy1)

The members of these pairs together contain the characters ‘a’, ‘b’ and ‘1’.
A pair (x, y) and (y, x) are to be treated the same.

Comments (3)