Written Test: 75 minutes online round (Cocubes) in which 3 simple questions were asked. A pool of questions was there and each person will get random questions in each difficulty level. CGPA cutoff was 7. Nearly, 45 people appeared for the test.
- Given an array of penalties, an array of car numbers and also the date. Output the total fine which will be collected on the given date.(Fine is collected from odd-numbered cars on even dates and vice versa). (2 marks).x
Input: Car numbers = {2375,7682,2325,2352} penalties = {250,500,350,200} Date = 12 Ans = 600
- Find the length of the longest proper prefix which is also a suffix.(3 marks).
- Count BST subtrees that lie in a given range.(5 marks).
- Find the missing number in the array
- Given a linked list. Find if it is palindrome or not. O(1) space.
- Convert the number to words. (0<= n <= 99,99,999).
Input: 5708 = five thousand seven hundred eight.
- Given two linked lists. Return True if all the elements in the first list are present in the second list.
Input: L1: 1->2->3 L2: 2->4->1->5->3 Ans: True
First, I told to use hashmap and to store and compare. Then he said no to use extra space. Then I said to traverse the two lists and delete the node from the second list whenever you find a match. He was satisfied with the approach and asked me to write it.
- Given a sorted rotated array and an element. Return the index of the element. I said O(n) approach first. Then I said to use binary search to find the pivot and then search the element. He asked if I can do it in one pass binary search. After discussing the approach he asked me to write the code.
- Print the level order traversal line by line. I used a queue to solve the problem. He was very much satisfied with my code. so, he asked me a simple question next.
- Given an array and the number. Find two elements whose sum is equal to the given number. First I said O(N2) solution. He asked me to optimize. Then I said to use the hashmap. He was satisfied and asked me to write the code. He asked how hashmap is implemented and what is the process inside it.
- He asked for my favorite language. Then he asked me questions on polymorphism and how it is implemented.
- You are given with a string with scrambled characters and the dictionary. Find all possible valid words which can be formed from the given string. I said to use Trie to store the dictionary and perform DFS to search in it. Then he said not to do unnecessary traversals. Then I asked him in what complexity he want. He said the best I can do. Then I told him to hash all the occurrence of the characters in each string in the dictionary. He asked me to prove that the hash function is collision free. I tried for a long time and he said it's okay.