Sunday, 7 November 2021

TCS Test

TCS Test Sample Questions

Below are the question pattern asked 
  • Verbal Ability - 20 Questions
  • Numerical Ability - 15 Questions
  • Reasoning Ability - 15 Questions
  • Hands On Coding Exercise - 2 Questions


Sample Coding Questions

Question1

Given a number, return UNO if sum of its digits its recursively ends up into 1 else NOT UNO

Solution


Wednesday, 6 October 2021

Apple Hacker Rank Test

Apple Hacker Rank Test

Apple Hacker Rank

Apple Hacker Rank Test

Q1 Connected Numbers

Numbers a and b are referred to as connected numbers if the digits in a can be replaced to get digits in b.
All occurrences of a digit must be converted at once. No two digits can be converted to the same digit.
If such a conversion is possible, print the minimum number of moves required for the conversion else print "Impossible".

Example1
Input
11223344 55227788

Output: 3

Explaination
Convert 1 to 5 -> 55223344
Convert 3 to 7 -> 55227744
Convert 4 to 8 -> 55227788

Example2
Input
1234 2334

Output: 2

Explaination
Convert 1 to 2 -> 2234
Convert 2 to 3 -> 2334

Saturday, 24 April 2021

Myntra Interview Experience

Myntra Software Engineer Interview Experience

Myntra Software Engineer Interview Experience
Round 1 - Problem Solving

Q1: Class room; number of student 1 to N.
We need to elect class leader such that
* Every student should trust L
* L shouldn’t trust anyone.
(x, y) => x trusts y

Input: N integer
Array pair of ints
Output: Integer  = L
(1, 4) (1,2) (2, 4) (3, 4) (1,2), (3, 2)

Edge cases

(1,2), (2, 3), (1,3), (3, 2)

(4, 1), (1, 4), (2, 4) (3, 4)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
TrustPairNode {
Integer key; //student
Integer value;//trust on student
}

Int getLeader(List<TrustPairNode> trustPair, int n) {
    Map<Integer, Integer> leaderMap = new HashMap<>();
    for (TrustPairNode node : trustPair) {
        // 4 -> 3
        leaderMap.put(node.value, leaderMap.getOrDefault(node.value, 0)++);
        // (1, 4) (1, 2) (2, 4) (3, 4) (1,2), (3, 2) (5, 4)

If (leaderMap.containsKey(node.key)) {
            leaderMap.remove(node.key);
        }
    }

    for (Map.Entry<Integer, Integer> entrySet : leaderMap.entrySet()) {
    If (entry.getValue() == n-1) {
        return entry.getKey();
    }
    return -1;
}