MakeMyTrip Coding Questions
Make My Trip Coding Questions 2023
Make My Trip Coding Questions is the part of Programming Assessment which is an Online Test. The level of these questions is exceptionally hard. Hence one needs to practice hard to clear these questions.
On this page you will find everything related to make my trip coding questions. You can even look for section bifurcation, eligibility criteria, salary breakdown on this page.
About MakeMyTrip
In 2000, MakeMyTrip, an online travel agency based in India, was established. It’s a business with its corporate office in Gurugram, Haryana.
The business offers a variety of travel-related services online, including airline tickets, domestic and foreign vacation packages, hotel bookings, and rail and bus tickets.
Prime Course Trailer
MakeMyTrip Eligibility Criteria
Here are some of the pointers which one need to keep in mind before you apply for the MMT recruitment drive. Check your eligibility once before applying.
- A CGPA of 7.0 throughout B.Tech
- No active backlogs
- CSE and IT students only applicable
MakeMyTrip Online Assessment
- Programming MCQs
- Coding
MakeMyTrip | Number of Questions | Time | Diifficulty |
---|---|---|---|
Programming MCQs | 20 | 90 mins (Shared) | Hard |
Coding | 2 | 90 mins (Shared) | Hard |
Analysis of Make My Trip Exam
- No. of Questions: 22
- Time Allotted : 90 mins
- Difficulty : High
MakeMyTrip Salary Breakdown
MakeMyTrip | Salary Breakdown |
---|---|
Fixed Component | Rs 13 Lakhs |
Retention Bonus | Rs 1.5 Lakhs |
Joining Bonus | Rs 1 Lakh |
RSUs | Rs 10 Lakhs |
At the time of Internship
- Before being converted into full-time employees, there will be an internship period.
- The stipend during the internship will Rs 35,000.
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription
MakeMyTrip Coding Questions
Question 1 : Choco and chocolate
Problem Statement :
Choco, a chocolate lover, has N amount of money with him. He wants to buy as much chocolate as possible. So, he goes to a chocolate shop “Bandyman ”. Mike, the owner of “Bandyman ” has different types of chocolate in his store (represented by a character) placed in a row.
Mike, give an offer to Choco that he can buy a selected type of chocolate for free and need to pay for the other types of chocolates and Choco can only buy consecutive chocolates.
Now, you need to write a code to find the maximum amount of chocolates Choco can get by selecting the chocolates optimally.
Input format :
1st line contains 2 space separated integers A and B denoting the number of chocolates and the amount of money Choco has.
The 2nd line contains A chocolates represented by a string. All chocolates represented by lowercase alphabets.
The 3rd line represents 26 space separated integers representing the cost to buy the chocolates.
[First integer represents the cost of the chocolate of type ‘a’, 2nd integer represents the cost of the chocolates of type ‘b’ and so on]
Output format :
Print the maximum number of chocolates Choco can buy.
Constraints :
1<=A<=10^5
1<=B<=10^9
1<=cost of chocolate<=10^9
Sample input 1 :
6 10
aabcda
5 4 4 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample output 1 :
4
Explanation :
Choco can select the chocolate of type ‘a’ for free and start buying from index 0 and if he buys “aabc” then he has to pay less (0+0+4+4=8) than the total money he has.
This is the maximum number of chocolates he can get in this case.
#include<bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string s, s1; cin >> s; cin.ignore(); getline(cin, s1); istringstream ss(s1); vector < int > a; vector < char > a1; while (ss) { string w; ss >> w; if (w == "") break; a.push_back(stoi(w)); } map < char, int > mm; for (auto i: s) if (mm[i] == 0) { mm[i]++; a1.push_back(i); } int t = 0; for (auto i: a1) { vector < int > a2; for (auto i1: s) { if (i1 == i) a2.push_back(0); else a2.push_back(a[i1 - 97]); } int l = 0, su = 0; for (int i2 = 0; i2 < n; i2++) { if (l == i2) su += a2[i2]; else su += a2[i2]; if (su > m) { while (su > m && l <= i2) { su -= a2[l]; l++; } } if (i2 - l + 1 > t) t = i2 - l + 1; } } cout << t; }
import java.util.*; class Main { public static int solve(int n, int amnt, String s, int[] price) { int[] freq = new int[26]; char[] ch = s.toCharArray(); int temp = 0, ans = 0, maxFreq = 0, st = 0; for (int i = 0; i < n; i++) { int indx = ch[i] - 'a'; freq[indx] += price[indx]; temp += price[indx]; maxFreq = Math.max(maxFreq, freq[indx]); if (temp - maxFreq > amnt) { while (temp > amnt) { boolean b = false; int tempIndx = ch[st] - 'a'; if (maxFreq == freq[tempIndx]) { b = true; } temp -= price[tempIndx]; freq[tempIndx] -= price[tempIndx]; st++; if (b) { maxFreq = 0; for (int j = 0; j < 26; j++) { maxFreq = Math.max(freq[j], maxFreq); } } if (temp - maxFreq < amnt) { break; } } } ans = Math.max(ans, i - st + 1); } return ans; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int amnt = sc.nextInt(); String s = sc.next(); int[] price = new int[26]; for (int i = 0; i < n; i++) { price[i] = sc.nextInt(); } System.out.println(solve(n, amnt, s, price)); } }
n, m = map(int, input().split()) s = input().strip() a = list(map(int, input().split())) s1 = set() for i in s: if i not in s1: s1.add(i) s1 = list(s1) t = 0 for i in s1: a1 = [] for i1 in s: if i1 == i: a1.append(0) else: a1.append(a[ord(i1) - 97]) l = 0 su = 0 for i2 in range(n): if l == i2: su = a1[i2] else: su += a1[i2] if su > m: while su > m and l <= i2: su -= a1[l] l += 1 if (i2 - l + 1) > t: t = i2 - l + 1 print(t)
Question 2 :Number with 2
Problem Statement :
Suppose you are in a number system, where if the number doesn’t contain 2 in the unit digit then the number is not valid. So the first number of the number system is 2, the second number is 12, and the third is 22.
for a given integer n, you have to print the nth element of the number system.
Input Format:
First line, containing n denoting the number of test cases.
then n number of lines for the query.
Output Format:
Print the consecutive number in the number system for each query.
Sample Input:
3
Sample Output:
22
Explanation:
1st number will be 2 , 2nd number will be 12 and third number will be 32
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << (n - 1) * 10 + 2; return 0; }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); System.out.println((n - 1) * 10 + 2); } }
n = int(input()) print((n - 1) * 10 + 2)
Question 3 : Vowel Encryption
Problem Statement :
There is an encryption game going on. You will be given a number. If a digit is prime, it will take a vowel. Otherwise it will take a consonant value.
By this process, you have to make the string the lexicographically smallest possible. For a given number, print the output as a string.;
Input Format:
An integer n denoting the number.
Output Format:
The encrypted word.
Sample Input: 123421
Sample Output: baecab
#include<bits/stdc++.h> using namespace std; map < char, char > M; map < int, bool > prime; int main() { prime[2] = true; prime[3] = true; prime[5] = true; prime[7] = true; char vow[] = { 'a', 'e', 'i', 'o', 'u' }; char con[] = { 'b', 'c', 'd', 'f', 'g', 'h' }; int jv = 0, jc = 0; string s; cin >> s; for (auto i: s) { if (prime[i - '0']) { if (M[i]) {} else { M[i] = vow[jv]; jv++; } } else if (M[i]) {} else { M[i] = con[jc]; jc++; } } for (auto i: s) cout << M[i]; }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String vowel = "aeiou"; char arr[] = new char[10]; arr[2] = 'a'; arr[3] = 'e'; arr[5] = 'i'; arr[7] = 'o'; char ch = 'b'; for (int i = 1; i < arr.length; i++) { if (vowel.indexOf(ch) != -1) { ch++; continue; } else if (arr[i] == 0) arr[i] = (char) ch++; } int temp = n; int res = 0; while (temp != 0) { res = res * 10 + temp % 10; temp = temp / 10; } int i = 1; while (res != 0) { System.out.print(arr[res % 10]); res = res / 10; } } }
s = input() res = [] x, y = 0, 0 v = "aeiou" c = "bcdfgh" p = "2357" ans = sorted(set(s)) for i in ans: if i in p: res.append(v[x]) x += 1 else: res.append(c[y]) y += 1 for i in s: print(res[ans.index(i)], end="")
Question 4 :Jack’s Text
Problem Statement :
Jack is learning to type english from the beginning and he is making an error of repeating the same words in his texts over whatsapp. Write a function that will take input for his text sent to you and then keep only the unique texts.
Note that, the uniqueness is about being word specific not position, there are nothing but alphabets in the sentences and words are separated only with white space.
Constraints:
Words in the line<=10^5
Alphabets in the words<=20
Sample Input:
Send send the image send to to to me
Output:
Send the mage to me
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; while (n) { n &= (n - 1); ans++; } cout << ans; }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); String arr[] = str.split(" "); String first = arr[0]; arr[0] = arr[0].toLowerCase(); LinkedHashMap < String, Boolean > map = new LinkedHashMap < String, Boolean > (); for (int i = 0; i < arr.length; i++) map.put(arr[i], true); Set s = map.entrySet(); Iterator itr = s.iterator(); System.out.print(first + " "); int j = 0; while (itr.hasNext()) { Map.Entry m = (Map.Entry) itr.next(); if ((Boolean) m.getValue() == true && j == 1) System.out.print(m.getKey() + " "); j = 1; } } }
arr = list(input().split()) dup = [] ans = "" for i in arr: if i not in dup: dup.append(i) ans += i + " " print(ans)
Question 5 :A Good Prime Number
Problem Statement :
A prime number is a number which is divisible by one and itself. Also a number is called a good prime number if the sum of its digits is a prime number. For example a number 23 is a good prime number because the sum of 2 and 3 ( 2+3=5) is 5 which is a prime number. You are given an integer K. Your task is to find the kth good prime number that is greater than a provided number N.
For example , 232 is a good prime number since the sum of all digits is 7 which is a prime number whereas 235 is not a good prime number.
Input format :
- The first line contains an integer N.
- The next line contains an integer K.
Output format :
A single integer which is a Kth good prime number that is greater than a provided number N.
Constraints :
- 1<=N<=10^5
- 1<=K<<=10^5
Sample Input 1:
4 4
Sample Output 1:
12
Explanation :
Good prime numbers starting from 4 are 5,7,11(1+1=2 which is prime number),12(1+2=3 which is prime number),14(1+4=5 which is a prime number) and so on. Because the sum of digits of an individual number is a prime number And 4 th good prime number is 12 in this series.Hence the output is 12.
Sample Input 2:
17 5
Sample Output 2:
29
Explanation :
Good prime numbers starting from 17 are 20,21,23,25,29…and the 5th prime number is 29.Hence the output is 29.
#include <iostream> #includeusing namespace std; bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if ((n % i == 0) || (n % (i + 2) == 0)) return false; return true; } int solve(int n, int k) { int c = 0; vector < int > list; for (int i = n + 1; c < k; i++) { int temp = i; int sum = 0; while (temp != 0) { sum = sum + temp % 10; temp = temp / 10; } if (isPrime(sum)) { list.push_back(i); c++; } } return list[k - 1]; } int main() { int n; cin >> n; int k; cin >> k; cout << solve(n, k); return 0; }
import java.util.*; class Main { public static boolean isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if ((n % i == 0) || (n % (i + 2) == 0)) return false; return true; } public static int solve(int n, int k) { int c = 0; ArrayList < Integer > list = new ArrayList < > (); for (int i = n + 1; c < k; i++) { int temp = i; int sum = 0; while (temp != 0) { sum = sum + temp % 10; temp = temp / 10; } if (isPrime(sum)) { list.add(i); c++; } } return list.get(k - 1); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); System.out.println(solve(n, k)); } }
import math def isPrime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False for i in range(5, int(math.sqrt(n)) + 1, 6): if n % i == 0 or n % (i + 2) == 0: return False return True def solve(n, k): c = 0 list = [] for i in range(n + 1, 1000000000): temp = i sum = 0 while temp != 0: sum = sum + temp % 10 temp = temp // 10 if isPrime(sum): list.append(i) c += 1 if c == k: break return list[k - 1] n, k = map(int, input().split()) print(solve(n, k))
FAQs on MakeMyTrip Coding Questions with Solutions
Question 1: What type of questions are asked in the MakeMyTrip Placement exam?
MakeMyTrip has programming mcqs and coding questions in its placement exam.
Question 2: Is Make My Trip exam difficult to crack?
MakeMyTrip exam is definitely not easy to crack as it is totally based on programming questions.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others
Login/Signup to comment