Autocoder

MakeMyTrip Coding Round Questions

Last updated 2026-11-19

Candidate reports describe MakeMyTrip online assessments as a small number of coding problems alongside MCQs. The domain is travel, so problems often hide in booking language: overlapping stays, cheapest routes with limited stops, nearest hotels, popular searches. This page gives eleven practice problems in that style, each with a worked solution, its complexity and the mistakes that cost marks.

These are practice problems in the style of the topics the round is reported to cover, not copies of any test. Pair them with MakeMyTrip interview questions for the technical and HR side, and with how to crack the DSA coding round for general strategy.

Format (reported)Coding problems plus MCQs, then DSA interviews
Languages herePython and Java
ThemesIntervals, graphs, heaps, hashing, caches

How to approach these problems

Translate the story into a standard pattern first: a room-booking problem is interval scheduling, a cheapest-flight problem is shortest path with a constraint, a most-searched-city problem is top-k frequency. Say the pattern aloud, give the brute force, then improve it.

In an online assessment, hidden test cases punish edge cases: empty input, a single element, equal timestamps, and answers that overflow 32-bit integers. Check each before submitting.

Hiring status

We hold no sourced drive dates, openings or cutoffs for MakeMyTrip, so none are given here. The round structure above is candidate-reported, not company-published. Check careers.makemytrip.com for what is currently open.

MakeMyTrip Coding Round Questions: questions with worked answers

  1. 1

    Minimum rooms needed for a list of booking intervals. Given start and end times of stays, find the minimum number of rooms so no two overlapping stays share a room.

    easy

    Sort starts and ends separately and sweep: each start takes a room, each end (at or before the next start) frees one. Track the maximum in use. Treating an end equal to a start as free matches a checkout and check-in at the same time, so use `<=` on the comparison. Sorting dominates: O(n log n) time, O(n) space. A common mistake is sorting only by start and forgetting that rooms free up in end order.

    python
    def min_rooms(stays):
        starts = sorted(s for s, e in stays)
        ends = sorted(e for s, e in stays)
        rooms = best = j = 0
        for s in starts:
            while ends[j] <= s:
                j += 1
                rooms -= 1
            rooms += 1
            best = max(best, rooms)
        return best
    
    print(min_rooms([(1, 4), (2, 5), (4, 6)]))  # 2
  2. 2

    Merge overlapping travel windows. Given date ranges when a hotel is blocked, merge overlaps.

    easy

    Sort by start, then extend the last merged range while the next start is at most its end. Whether ranges that merely touch (end equals next start) should merge depends on the statement, so ask. O(n log n) time, O(n) space for the output. The common error is comparing with the next interval's end instead of the running maximum end, which breaks on nested ranges like [1,10], [2,3].

    python
    def merge(ranges):
        ranges.sort()
        out = []
        for s, e in ranges:
            if out and s <= out[-1][1]:
                out[-1][1] = max(out[-1][1], e)
            else:
                out.append([s, e])
        return out
    
    print(merge([[1, 3], [2, 6], [8, 10]]))  # [[1, 6], [8, 10]]
  3. 3

    Cheapest flight within K stops. Given flights as (from, to, price), find the cheapest price from src to dst with at most K stops, or -1.

    medium

    Run Bellman-Ford limited to K+1 edges. Each round relaxes edges using a copy of the previous round's distances; using the same array lets a path use more edges than allowed in one pass. Complexity: O(K * E) time, O(V) space. Dijkstra on plain cost fails because a cheaper path with too many stops can hide a valid costlier one; if you use Dijkstra, the state must include stops used.

    python
    def cheapest(n, flights, src, dst, k):
        INF = float('inf')
        dist = [INF] * n
        dist[src] = 0
        for _ in range(k + 1):
            nxt = dist[:]
            for u, v, w in flights:
                if dist[u] + w < nxt[v]:
                    nxt[v] = dist[u] + w
            dist = nxt
        return -1 if dist[dst] == INF else dist[dst]
    
    print(cheapest(3, [(0,1,100),(1,2,100),(0,2,500)], 0, 2, 1))  # 200
  4. 4

    K closest hotels to the user. Given hotel coordinates and a user location, return the k nearest.

    medium

    Keep a max-heap of size k keyed on squared distance (no square root needed, and it avoids float error). Push each hotel and pop the largest when size exceeds k. O(n log k) time, O(k) space; better than sorting everything when k is small. In Java use a PriorityQueue with a reversed comparator. Mistake: using a min-heap of all n points and popping k, which is fine but O(n + k log n) and uses more memory.

    java
    import java.util.*;
    
    public class Nearest {
        public static int[][] kClosest(int[][] pts, int ux, int uy, int k) {
            PriorityQueue<int[]> pq = new PriorityQueue<>(
                (a, b) -> Long.compare(d(b, ux, uy), d(a, ux, uy)));
            for (int[] p : pts) {
                pq.offer(p);
                if (pq.size() > k) pq.poll();
            }
            return pq.toArray(new int[0][]);
        }
        static long d(int[] p, int ux, int uy) {
            long dx = p[0] - ux, dy = p[1] - uy;
            return dx * dx + dy * dy;
        }
    }
  5. 5

    LRU cache for recently viewed hotels. Implement get and put in O(1) with a fixed capacity.

    medium

    Combine a hash map with a doubly linked list: the map finds a node in O(1), the list orders recency. On get, move the node to the front; on put, insert at the front and evict the tail if over capacity. In Python, OrderedDict does exactly this. All operations are O(1), space O(capacity). Mistake: updating an existing key without moving it to the front, so a hot key is evicted.

    python
    from collections import OrderedDict
    
    class LRU:
        def __init__(self, cap):
            self.cap, self.d = cap, OrderedDict()
    
        def get(self, k):
            if k not in self.d:
                return -1
            self.d.move_to_end(k)
            return self.d[k]
    
        def put(self, k, v):
            self.d[k] = v
            self.d.move_to_end(k)
            if len(self.d) > self.cap:
                self.d.popitem(last=False)
  6. 6

    Top K most searched cities from a stream of queries.

    medium

    Count with a hash map, then take the k largest counts using a size-k min-heap, or heapq.nlargest. O(n + m log k) where m is the number of distinct cities. For a true unbounded stream, use an approximate structure such as Count-Min Sketch. Mistake: sorting the whole dictionary when k is tiny, and not defining tie-breaking, which the problem may require (for example alphabetical).

    python
    import heapq
    from collections import Counter
    
    def top_k(queries, k):
        cnt = Counter(queries)
        return [c for c, _ in heapq.nsmallest(k, cnt.items(), key=lambda x: (-x[1], x[0]))]
    
    print(top_k(["goa","delhi","goa","pune","delhi","goa"], 2))  # ['goa', 'delhi']
  7. 7

    Longest stay window without a repeated city. Find the longest substring (or subarray) with all distinct elements.

    medium

    Sliding window with a map from character to its last index. When the current character was seen inside the window, move the left edge past that index. O(n) time, O(min(n, alphabet)) space. Mistake: moving left backwards when the stored index is older than the current left; always take the maximum of left and last+1.

    java
    import java.util.*;
    
    public class Distinct {
        public static int longest(String s) {
            Map<Character, Integer> last = new HashMap<>();
            int left = 0, best = 0;
            for (int i = 0; i < s.length(); i++) {
                Integer j = last.get(s.charAt(i));
                if (j != null) left = Math.max(left, j + 1);
                last.put(s.charAt(i), i);
                best = Math.max(best, i - left + 1);
            }
            return best;
        }
    }
  8. 8

    Cheapest day in every window of k days. For daily fares, output the minimum in each window of size k.

    medium

    Use a monotonic deque of indexes whose fares are increasing; the front is the window minimum. Pop from the back while the new fare is smaller, and pop from the front when its index leaves the window. Each index enters and leaves once: O(n) time, O(k) space. Mistake: recomputing min over every window, which is O(nk).

    python
    from collections import deque
    
    def window_min(a, k):
        dq, out = deque(), []
        for i, x in enumerate(a):
            while dq and a[dq[-1]] >= x:
                dq.pop()
            dq.append(i)
            if dq[0] <= i - k:
                dq.popleft()
            if i >= k - 1:
                out.append(a[dq[0]])
        return out
    
    print(window_min([5, 3, 4, 8, 2], 3))  # [3, 3, 2]
  9. 9

    Number of connected regions of available hotels in a grid (islands).

    medium

    Scan the grid; when you meet an unvisited 1, count a region and flood-fill its neighbours with DFS or BFS, marking cells visited. O(rows * cols) time. A recursive DFS can overflow the stack on a large grid, so use an explicit stack or BFS queue for big inputs. Mistake: forgetting bounds checks, or counting diagonal neighbours when the statement says four-directional.

    python
    def regions(g):
        R, C = len(g), len(g[0])
        seen = set()
        def fill(r, c):
            stack = [(r, c)]
            seen.add((r, c))
            while stack:
                x, y = stack.pop()
                for nx, ny in ((x+1,y),(x-1,y),(x,y+1),(x,y-1)):
                    if 0 <= nx < R and 0 <= ny < C and g[nx][ny] == 1 and (nx, ny) not in seen:
                        seen.add((nx, ny))
                        stack.append((nx, ny))
        n = 0
        for r in range(R):
            for c in range(C):
                if g[r][c] == 1 and (r, c) not in seen:
                    n += 1
                    fill(r, c)
        return n
  10. 10

    Maximum profit from at most two flight-ticket trades. Given daily prices, buy and sell at most twice without overlapping.

    hard

    Track four running values: best after first buy, first sell, second buy and second sell. Each day update them in order, using the previous values. O(n) time, O(1) space. Mistake: allowing the second buy before the first sell completes; keeping the updates in the right order, using values from the same day carefully, handles it.

    python
    def max_profit(p):
        b1 = b2 = float('-inf')
        s1 = s2 = 0
        for x in p:
            b1 = max(b1, -x)
            s1 = max(s1, b1 + x)
            b2 = max(b2, s1 - x)
            s2 = max(s2, b2 + x)
        return s2
    
    print(max_profit([3,3,5,0,0,3,1,4]))  # 6
  11. 11

    Detect a cycle in a dependency graph of booking steps and return a valid order.

    hard

    This is topological sorting. Kahn's algorithm: compute in-degrees, queue nodes with zero, repeatedly remove one and decrement neighbours. If fewer than n nodes are output there is a cycle. O(V + E). Mistake: DFS without distinguishing "in the current path" from "finished", which reports false cycles on diamond-shaped graphs.

    python
    from collections import deque
    
    def order(n, edges):
        adj = [[] for _ in range(n)]
        indeg = [0] * n
        for u, v in edges:
            adj[u].append(v)
            indeg[v] += 1
        q = deque(i for i in range(n) if indeg[i] == 0)
        res = []
        while q:
            u = q.popleft()
            res.append(u)
            for v in adj[u]:
                indeg[v] -= 1
                if indeg[v] == 0:
                    q.append(v)
        return res if len(res) == n else None

Frequently asked questions

What difficulty are MakeMyTrip coding problems?

Candidate reports describe easy to medium problems, with occasional harder graph or dynamic programming questions in interviews. Practise intervals, heaps, sliding windows and graph traversal until the pattern is automatic.

Which language should I use?

Use the one you are fastest in. Python is compact for online assessments; Java is fine and common. Know your language's heap and hash map APIs cold.

Are these the real MakeMyTrip questions?

No. They are practice problems in the style of the topics commonly reported, written for preparation, and not a copy of any test.

How should I split time between DSA and CS fundamentals?

Most reports mention both. Spend roughly two thirds on problems and one third on OS, DBMS and OOP, and revisit your own projects for the interview.

Does the online assessment have MCQs?

Candidate reports mention MCQs alongside coding in some years. The format is not published, so confirm it in your invitation email.

Sources

Related guides

More in Company Interview Questions

See all in this section