MakeMyTrip Interview Experience | Set 5 (Online Coding)
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<Integer> l = new ArrayList<Integer>(); 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; } } |
chevron_right
filter_none
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.
Recommended Posts:
- MakeMyTrip Interview Experience | Set 6 (Online Coding)
- Atlassian Online Coding Interview Experience
- BrowserStack Interview Experience | Set 7 (Online Coding Questions)
- Microsoft Interview Experience | Set 141 (Off-Campus - Online Coding Test for IDC)
- Tesco Bengaluru Interview Experience | Set 1 (Online Coding Test)
- Fiberlink (maas360) Interview Experience | Set 5 (Online Coding Question)
- MakeMyTrip Interview Experience | Set 12
- MakeMyTrip Interview Experience | Set 16
- MakeMyTrip Interview Experience
- MakeMyTrip Interview Experience | Set 4
- MakeMyTrip Interview Experience | Set 3
- MakeMyTrip interview experience 2018
- MakeMyTrip Interview Experience | Set 2 (On-Campus)
- MakeMyTrip Interview Experience (On-Campus)
- MakeMyTrip Interview Experience 2019



