Skip to content
Related Articles
MakeMyTrip Interview Experience | Set 5 (Online Coding)
• Last Updated : 21 Mar, 2015

Question 1: Given an array with n elements consisting of numbers between 1 to n-1 with some numbers being repeated multiple times in the array.
Give a result[] array as output containing all the repeated/duplicate elements.

 `Code:   ``package` `arrays;``=====``import` `java.util.ArrayList;`` ` `public` `class` `MultipleDuplicateValues {`` ` `    ``public` `static` `void` `main(String[] args) {`` ` `        ``int` `arr[] = { ``1``, ``2``, ``3``, ``1``, ``3``, ``6``, ``6` `};``        ``int``[] result = getduplicates(arr);``        ``for` `(``int` `i = ``0``; i < result.length; i++) {``            ``System.out.println(Math.abs(result[i]));``        ``}`` ` `    ``}`` ` `    ``private` `static` `int``[] getduplicates(``int``[] arr) {``        ``ArrayList l = ``new` `ArrayList();``        ``int``[] result;``        ``for` `(``int` `i = ``0``; i < arr.length; i++) {``            ``if` `(arr[Math.abs(arr[i])] >= ``0``) {``                ``arr[Math.abs(arr[i])] = -arr[Math.abs(arr[i])];``            ``} ``else` `{``                ``l.add(arr[i]);``            ``}`` ` `        ``}`` ` `        ``result = ``new` `int``[l.size()];``        ``int` `i = ``0``;``        ``while` `(i < l.size()) {``            ``result[i] = l.get(i);``            ``i++;``        ``}`` ` `        ``return` `result;``    ``}``}`

Question 2: Given an array containing a sequence of numbers , you need to identify whether that sequence is Fibonacci , Arithmetic Expression or Geometric Expression
============ And give it’s next term as output.

Total time for the above two questions : 45 Minutes

Mode of interview : Online Coding

If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.

My Personal Notes arrow_drop_up