Yatra.com interview questions

103 questions from 11 interviews · updated from reports 2013-2023

Practise Yatra.com-style

About

Yatra.com is an Indian online travel company that lets users search and book flights, hotels, holiday packages, buses, trains, and related travel services. In India, it is known for hiring Software Engineers, Software Developers, and Senior Software Engineers.

The roles that come up most are Software Engineer, Software Developer and Senior Software Engineer. This covers 11 candidate interviews reported from 2013 to 2023. Most sat it at entry level (8 of 10 that recorded a level). Among the 4 that recorded either route, arrivals split between campus drives (2, 50%) and off-campus applications (2, 50%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Design an elevator system.

asked 1xmediumObject oriented designTechnical2017

Ans. Design it as controllers managing elevators, requests and scheduling, with each elevator tracking current floor, direction, state, capacity and assigned stops. The key detail is the dispatch algorithm: group requests by direction and allocate the nearest suitable elevator, while each elevator serves stops in order before reversing, minimising wait and travel time.

Q. Implement your own hash map.

asked 1xmediumOOPTechnical2017

Ans. Use an array of buckets, where each bucket holds key value pairs, commonly as a linked list or dynamic array for collisions. Hash the key, take modulo capacity to find the bucket, then search within it. Put, get, and delete are average O(1), but worst case O(n). Resize when load factor grows.

Q. Rotate a matrix by 90 degrees clockwise.

asked 1xmediumArraysTechnical2015

Ans. Transpose the square matrix in place, then reverse each row to rotate it 90 degrees clockwise. Transposing swaps matrix[i][j] with matrix[j][i], and reversing rows moves each element into its final clockwise position. This uses the matrix itself as the data structure, taking O(n²) time and O(1) extra space.

Q. Perform spiral traversal of a binary tree.

asked 1xmediumTreesTechnical2017

Ans. Perform spiral traversal using level order traversal with alternating direction at each level. Use a queue to process nodes level by level, and either reverse the collected level values on alternate levels or use two stacks to control order. The traversal visits every node once, so time complexity is O(n) and space complexity is O(w).

Q. Explain dynamic dispatch and virtual dispatch.

asked 1xmediumOOPTechnical2023

Ans. Dynamic dispatch means choosing which method implementation to call at runtime, based on the actual object type rather than the reference type. Virtual dispatch is the common mechanism for this in object-oriented languages, using virtual methods, often via a vtable. It enables overriding and polymorphism, with small runtime overhead.

Q. Operating Systems concepts and theory questions.

asked 1xmediumOperating systemsTechnical2017

Ans. Please provide the specific operating systems question you want answered. I can then give a direct 40 to 60 word interview-style response covering the key concept, such as processes, threads, scheduling, deadlocks, memory management, paging, virtual memory, file systems, system calls, synchronisation, or concurrency.

Q. What is Core Data and how does it work internally?

asked 1xmediumDBMSTechnical2023

Ans. Core Data is Apple’s object graph and persistence framework for managing model objects, usually backed by SQLite. Internally, a managed object context tracks objects, changes and faults, then talks through a persistent store coordinator to a store. The key detail is that it is not just a database wrapper; it manages identity, relationships, validation and lazy loading.

Q. Reverse nodes of a linked list in groups of size K.

asked 1xmediumLinked listsTechnical2015

Ans. Reverse each block of K nodes by relinking pointers in place, leaving any final block with fewer than K nodes unchanged. Use a dummy head, first check that K nodes exist, then reverse that segment and reconnect it to the previous and next parts. This uses constant extra space and runs in O(n) time.

Q. Given a binary tree, convert it into a right-skewed tree.

asked 1xmediumTreesTechnical2017

Ans. Flatten the tree in preorder so each node’s right pointer points to the next preorder node and each left pointer becomes null. Use a reverse preorder traversal, visiting right then left, and keep a previous node pointer. Set current.right to previous, current.left to null, then update previous. Time is O(n), space is O(h).

Q. What will you do if you have a conflict with your manager?

asked 1xmediumConflict resolutionManagerial2015

Ans. Choose a real, low-drama example where you disagreed on priorities, approach, or timelines. Emphasise staying respectful, seeking to understand their reasoning, using facts, and aligning on the business goal. Interviewers listen for maturity, openness to feedback, ability to challenge constructively, and commitment to the final decision once agreed.

Q. Rotate a 2D matrix by 90 degrees without using extra space.

asked 1xmediumArraysTechnical2015

Ans. Transpose the square matrix in place, then reverse each row to rotate it 90 degrees clockwise. The transpose swaps matrix[i][j] with matrix[j][i] for the upper triangle only, avoiding double swaps. Reversing every row completes the rotation. This uses O(1) extra space and O(n²) time.

Q. What are Generics and Any in Swift? Explain their use cases.

asked 1xmediumSwift languageTechnical2023

Ans. Generics let you write type-safe, reusable code that works with different concrete types, while Any can store a value of any type with type information erased. Use generics for functions, collections, and types where relationships between types matter. Use Any only for heterogeneous values or bridging, because it loses compile-time type safety.

Q. How would you handle pagination in an iOS app consuming APIs?

asked 1xmediumMobile designSystem design2023

Ans. I would use server-driven pagination, preferably cursor-based, and keep paging state in the data layer, not the view. The app tracks items, next cursor, loading state, and end-of-list state. It fetches the next page when the user nears the bottom, deduplicates results, handles errors with retry, and avoids overlapping requests.

Q. Design a class diagram for a Training and Placement Cell system.

asked 1xmediumOOPTechnical2017

Ans. Use classes Student, Company, JobPosting, Application, Interview, Offer, PlacementOfficer and TrainingSession. Student applies to JobPosting, JobPosting belongs to Company, Application links Student and JobPosting, and Interview and Offer depend on Application. PlacementOfficer manages companies, postings and schedules. TrainingSession is attended by many Students and conducted or organised by an officer.

Q. How do you check if a binary tree is a Binary Search Tree (BST)?

asked 1xmediumTreesTechnical2015

Ans. Check it by recursively validating each node against an allowed value range. For a BST, every node in the left subtree must be less than the current node, and every node in the right subtree greater, with bounds carried down from ancestors. This takes O(n) time and O(h) recursion space.

Q. Given a string like "aaabbbccc", convert it in-place to "a3b3c3".

asked 1xmediumStringsTechnical2015

Ans. Scan the character array left to right, count each run, and write the character followed by the decimal count at a separate write position. Use two indices, read and write, with no extra data structure beyond a few variables. This is safe in-place here because the compressed form is not longer. Time is O(n).

Q. How would you design offline support and offline views in an iOS app?

asked 1xmediumMobile designSystem design2023

Ans. I would make the app local-first: views read from a local store such as Core Data or SQLite, while background sync keeps it aligned with the server. The key detail is a reliable sync layer: cache fetched data, queue offline writes, retry with backoff, track versions or timestamps, and handle conflicts explicitly.

Q. Check whether a given binary tree is a Binary Search Tree (BST) or not.

asked 1xmediumTreesTechnical2013

Ans. Use a DFS that carries the valid value range for each node. For a BST, every node must be greater than all values in its left subtree and less than all values in its right subtree. Start with infinite bounds, update them while recursing, and fail on any violation. Time is O(n), space is O(h).

Q. Given a binary tree, check whether all leaf nodes are at the same level.

asked 1xmediumTreesTechnical2013

Ans. Use a depth first traversal and record the depth of the first leaf found. For every other leaf, compare its depth with that recorded value; if any differs, return false. The data structure is the recursion stack, or an explicit stack. Time complexity is O(n), and space is O(h).

Q. What is the difference between layoutSubviews and layoutIfNeeded in iOS?

asked 1xmediumIos uiTechnical2023

Ans. layoutSubviews is where a view positions and sizes its subviews, while layoutIfNeeded asks UIKit to perform layout immediately if the view has been marked as needing it. Usually you override layoutSubviews for custom layout, and call layoutIfNeeded after setNeedsLayout or constraint changes when you need updated frames now.

Q. Compare MVVM and VIPER architectures in iOS. Which one is better and why?

asked 1xmediumArchitectureTechnical2023

Ans. MVVM is usually better for most iOS apps because it is simpler, faster to develop, and works well with SwiftUI, Combine, and reactive bindings. VIPER gives stricter separation into View, Interactor, Presenter, Entity, and Router, which helps very large teams and complex modules, but often adds boilerplate and slower iteration.

Q. Implement an iOS assignment to display a list of objects fetched from an API.

asked 1xmediumMobile designSystem design2023

Ans. I would build a simple MVVM screen with a table or collection view, an API client using URLSession, Codable models, and a view model exposing loading, success and error states. The key detail is keeping networking, parsing and UI separate, then updating the list on the main thread with pagination and retry handling if needed.

Q. Design database tables to retrieve all employees working under a given manager.

asked 1xmediumDBMSManagerial2015

Ans. Use an Employee table with employee_id as the primary key and manager_id as a foreign key back to Employee.employee_id. This models the hierarchy as an adjacency list. To retrieve everyone under a manager, use a recursive query starting from that manager’s direct reports. Index manager_id for efficient subordinate lookups.

Q. Given an array, find if there exists a triplet whose sum equals a given number.

asked 1xmediumArraysTechnical2017

Ans. Sort the array, then fix each element in turn and use two pointers on the remaining range to look for the required remaining sum. Move the left pointer right if the sum is too small, and the right pointer left if too large. This takes O(n²) time and O(1) extra space.

Q. Design a stack that supports finding the maximum element (findMax) in O(1) time.

asked 1xmediumStackTechnical2013

Ans. Use two stacks: the normal stack for values and an auxiliary stack that tracks the current maximum. On push, also push the new value to the max stack if it is greater than or equal to the current max. On pop, remove from max stack if the popped value equals its top. findMax returns max stack top in O(1).

Q. Find all words in a text that match a given pattern using an efficient algorithm.

asked 1xmediumStringsManagerial2015

Ans. Use KMP to scan the text and return matches whose start and end are word boundaries. Build the LPS prefix array for the pattern, then scan characters without backing up in the text. This uses an array for LPS, takes O(n + m) time and O(m) space.

Q. Given three sorted arrays, find the elements that are common in all three arrays.

asked 1xmediumArraysOnline test2015

Ans. Use three pointers, one for each sorted array, and move them to find equal values in all three arrays. If all three values match, record it and advance all pointers, skipping duplicates if unique output is needed. Otherwise, advance the pointer with the smallest value. Time complexity is O(n1 + n2 + n3) with O(1) extra space.

Q. Explain the differences between Objective-C and Swift, including why Swift is faster.

asked 1xmediumProgramming languagesTechnical2023

Ans. Swift is a modern, type-safe, statically dispatched language, while Objective-C is older, more dynamic, and built around C with Smalltalk-style messaging. Swift is usually faster because the compiler knows more types at compile time, can optimise calls and memory use better, and avoids much of Objective-C’s runtime message dispatch overhead.

Q. Given a string, print all substrings that start with a vowel and end with a consonant.

asked 1xmediumStringsOnline test2017

Ans. Scan the string, and for every index containing a vowel, extend a second pointer to the right and print the substring whenever that ending character is a consonant. No extra data structure is needed apart from the input string and loop variables. This takes O(n²) time and O(1) extra space.

Q. In a binary tree, find all left-facing elements using recursion and without recursion.

asked 1xmediumTreesTechnical2015

Ans. Left-facing elements are the left view: the first node seen at each depth when looking from the left. Recursively, do preorder DFS, visiting left before right, and record a node only when its level is first reached. Without recursion, use a queue for level-order traversal and record the first node of each level. Time is O(n).

Q. Given a 2D array that is sorted both horizontally and vertically, find a given element.

asked 1xmediumArraysTechnical2015

Ans. Start at the top right element and compare it with the target. If it is equal, return found. If it is greater, move left because everything below is larger. If it is smaller, move down because everything to the left is smaller. This eliminates one row or column each step, so time is O(rows + columns).

Q. Given a table (EmpID, Salary), write a generic SQL query to get the nth highest salary.

asked 1xmediumSQLTechnical2015

Ans. Use a subquery that selects salaries whose count of distinct salaries greater than them is n minus 1, then return that salary. The key detail is to count distinct salaries, so duplicates do not change the rank. With an index on Salary, the database can evaluate it more efficiently, though exact complexity depends on the optimiser.

Q. Find the inorder traversal of a binary tree when preorder and postorder traversals are given.

asked 1xmediumTreesOnline test2017

Ans. You generally cannot uniquely find the inorder traversal from preorder and postorder alone. The missing detail is tree structure: different binary trees can have the same preorder and postorder traversals but different inorder traversals. If the tree is known to be full, it can be reconstructed recursively, then inorder is obtained by left, root, right.

Q. For each element in an array, count how many previously appeared elements are smaller than it.

asked 1xmediumArraysTechnical2015

Ans. Use a Fenwick tree with coordinate compression, scanning the array from left to right. For each value, query the tree for the number of seen values with compressed rank less than its rank, then add the current value to the tree. Equal values are excluded. This runs in O(n log n) time.

Q. Check whether a given linked list is a palindrome. Write optimized code handling all edge cases.

asked 1xmediumLinked listsTechnical2013

Ans. Use two pointers to find the middle, reverse the second half in place, then compare both halves node by node. Empty and single-node lists are palindromes, and odd lengths skip the middle node. This uses only pointer manipulation, runs in O(n) time, and needs O(1) extra space.

Q. Given a group of people, find the celebrity if one exists using the celebrity problem constraints.

asked 1xmediumStackTechnical2017

Ans. Use two passes: first find a candidate by eliminating anyone who knows someone else, then verify the candidate. Keep one candidate index and scan all people; if candidate knows i, set candidate to i. Then check everyone: celebrity knows nobody, and everyone knows celebrity. This uses constant space and O(n) time.

Q. Given a string, return all possible subsequences that start with a vowel and end with a consonant.

asked 1xmediumStringsTechnical2017

Ans. Generate subsequences by choosing a vowel as the first character and a later consonant as the last character, then include or exclude each character between them using backtracking. Store each built subsequence in a list. Since subsequences can be exponential, the time and output size are O(2^n), with O(n) recursion depth.

Q. Explain an algorithm for level order traversal of a binary search tree without using a queue data structure.

asked 1xmediumTreesTechnical2014

Ans. Use recursive level printing: first compute the tree height, then for each level from 1 to height, recursively visit the tree and print nodes whose depth matches that level. The key detail is that this avoids an explicit queue, but costs more time: O(nh), worst case O(n²), with O(h) recursion space.

Q. Given an integer array and a value k, count the number of contiguous subarrays whose product is less than k.

asked 1xmediumArraysOnline test2017

Ans. Use a sliding window with two pointers and a running product, assuming all numbers are positive. Expand the right pointer, multiply by the new value, and while the product is at least k, divide out the left value and move left. Add right minus left plus one each step. Time is O(n), space is O(1).

Q. In Objective-C, can we assign any type of object to any type of variable? If yes, how can this be restricted?

asked 1xmediumType systemTechnical2023

Ans. Yes, if the variable is typed as id, Objective-C can hold a reference to any object. This is dynamic typing, and method checks are mostly deferred to runtime. To restrict it, declare the variable with a specific class type, such as NSString *, or use a protocol type such as id<MyProtocol>.

Q. Explain the differences between class and struct in Swift, including where they are created and stored in memory.

asked 1xmediumOOPTechnical2023

Ans. In Swift, structs are value types and classes are reference types. A struct instance is stored inline where it is used, often on the stack for local values, while a class instance is created on the heap and variables store references to it. Struct assignments copy values, but class assignments share the same object.

Q. Given an unsorted array, print all pairs with a given sum. Modify the solution to avoid printing duplicate pairs.

asked 1xmediumArraysTechnical2013

Ans. Use a hash set while scanning the array: for each value x, check whether sum minus x has already been seen, and print the pair if it has. To avoid duplicate pairs, store each printed pair as ordered values, smaller first, in another set. This runs in O(n) time and O(n) space.

Q. Check whether two strings are anagrams of each other. How would the approach change if the strings are very large?

asked 1xmediumStringsTechnical2013

Ans. Use character frequency counts: if lengths differ, return false; otherwise count characters in one string and subtract counts using the other, ensuring all counts end at zero. This is O(n) time and O(k) space. For very large strings, process them in chunks or streams, keeping only the frequency table in memory.

Q. Find the vertical sum of nodes present in the same vertical line in a binary tree and print sums from left to right.

asked 1xmediumTreesTechnical2015

Ans. Assign each node a horizontal distance from the root, with root as 0, left child as distance minus 1, and right child as distance plus 1. Traverse the tree, store sums in an ordered map keyed by distance, then print values in key order. Time is O(n log n), space is O(n).

Q. If a struct has a class property, where is the object stored in memory? And vice versa if a class has a struct property?

asked 1xmediumMemory managementTechnical2023

Ans. A struct with a class property stores only a reference inside the struct; the referenced object itself is on the managed heap. A class with a struct property stores the struct’s value inline as part of the class object, which is also on the heap. The key distinction is reference versus value storage.

Q. If your team lead has provided one design and you have created another, how will you persuade the team to follow your design?

asked 1xmediumLeadershipManagerial2015

Ans. Choose a situation where you disagreed respectfully and used evidence, not authority or ego. Emphasise understanding the lead’s design first, comparing trade-offs, prototyping or measuring impact, and inviting feedback. Interviewers listen for collaboration, humility, clear reasoning, customer or business focus, and willingness to support the final team decision.

Q. Given a file containing characters (from the full ASCII set), design an algorithm to check whether the parentheses in the file are balanced.

asked 1xmediumStacksTechnical2014

Ans. Scan the file character by character and keep a count of unmatched opening parentheses. Increment on ‘(’, decrement on ‘)’, and if the count ever becomes negative, the parentheses are not balanced. Ignore all other ASCII characters. At the end, the file is balanced only if the count is zero. This is O(n) time and O(1) space.

Q. Given an array containing both positive and negative numbers, find three numbers whose sum is equal to a given value x in less than O(n^3) time.

asked 1xmediumArraysTechnical2014

Ans. Sort the array, then fix one element and use two pointers on the remaining range to find a pair summing to x minus that element. Move the left pointer up if the sum is too small, and the right pointer down if it is too large. This takes O(n²) time and O(1) extra space.

Q. Given two strings, return the minimum number of manipulations required so that both strings have identical characters (i.e., make them anagrams).

asked 1xmediumStringsTechnical2017

Ans. Count character frequencies in both strings and compare them; the minimum deletions needed is the sum of absolute frequency differences for every character. Use a hash map or fixed-size array for character counts. If the strings are equal length and manipulation means replacement, the answer is half that difference. Time complexity is O(n + m).

Q. Given an array of integers, find the maximum size of a subset that forms consecutive numbers (e.g., input: [4,5,6,13] → output: 3 for subset {4,5,6}).

asked 1xmediumArraysOnline test2017

Ans. Use a hash set and find the longest consecutive run of values. Insert all numbers into the set, then for each number that has no predecessor, meaning x minus 1 is absent, count upwards while x plus 1, x plus 2, and so on exist. The maximum count is the answer, in O(n) time.

Q. How would you apply Auto Layout constraints if there are three labels in a cell, arranged horizontally and vertically, and each can grow to multiple lines?

asked 1xmediumIos uiTechnical2023

Ans. Use Auto Layout with a self-sizing cell, putting the three labels in appropriate horizontal or vertical stack views, pinned to the contentView on all sides. Set each label to numberOfLines = 0, give sensible hugging and compression resistance priorities, and ensure there is an unbroken constraint path from top to bottom.

Q. Birthday problem: Given an array of ages, distribute chocolates such that any friend older than an adjacent neighbor gets more chocolates; compute chocolates for each and the total.

asked 1xmediumGreedyOnline test2015

Ans. Assign one chocolate to everyone, scan left to right increasing a friend’s chocolates if they are older than the left neighbour, then scan right to left fixing cases where they are older than the right neighbour. The chocolates for each friend are the final values, and the total is their sum. Time is O(n).

Q. Given a binary matrix where each row contains 0s and 1s sorted, find the index of the row with the maximum number of 1s. Follow-up: some rows are sorted in increasing order and some in decreasing order.

asked 1xmediumArraysTechnical2014

Ans. Use the top-right walk for increasing rows: start at column n minus 1, move left while you see 1s and record the row, otherwise move down, giving O(m + n) time and O(1) space. For mixed order rows, detect direction from the ends and binary search each row for its 1 count in O(m log n).

Q. Given two arrays: one of size n+m containing only m elements (rest are empty slots) and another of size n containing n elements, design an algorithm to merge the smaller array into the larger one such that the larger array remains sorted. Provide three different algorithms.

asked 1xmediumArraysTechnical2014

Ans. Three algorithms are: copy both arrays into a temporary array, sort it, and copy back; merge with two pointers into extra space; or merge in place from the end. The best method compares the last valid element of the large array and the last element of the small array, filling slots backwards in O(n+m) time and O(1) space.

Q. Reverse the elements of a stack without using another stack, queue, or array.

asked 1xhardStackTechnical2015

Ans. Reverse the stack using recursion: pop the top item, recursively reverse the remaining stack, then insert the popped item at the bottom. The key operation is insert-at-bottom, also done recursively by popping until the stack is empty. This uses no extra stack, queue, or array, but uses the call stack. Time is O(n²), space is O(n).

Q. Explain JSP, Servlets, and Java concepts with emphasis on memory-level behavior.

asked 1xhardJavaTechnical2015

Ans. JSP is a view template that is translated into a Servlet, while Servlets are Java classes running in a web container to handle HTTP requests. At memory level, request-handling threads have their own stacks, objects live on the heap, class metadata is in Metaspace, and shared Servlet instance fields must be avoided or synchronised because requests run concurrently.

Q. Clone a linked list in which each node has a random pointer in addition to the next pointer.

asked 1xhardLinked listsTechnical2015

Ans. Clone it by interleaving copied nodes with original nodes, then fixing random pointers, then separating the two lists. For each original node, create its copy as the next node. The copy’s random is original.random.next. Finally restore original next links and extract copy links. This takes O(n) time and O(1) extra space.

Q. Given a string, find all palindromic substrings and return the maximum product of the lengths of two palindromic substrings.

asked 1xhardStringsOnline test2017

Ans. Use Manacher’s algorithm to get the longest palindrome radius at each centre, then build arrays holding the best palindromic substring length ending at or before each index and starting at or after each index. Try every split and maximise leftBest[i] * rightBest[i+1]. This gives linear time and linear space.

Q. Given a 2D matrix containing values 0 (blocked), 1 (open path), and 2 (open path with cheese), Tom starts at (0,0) and Jerry’s location is given. Find an optimal path for Tom to collect all cheese and then catch Jerry.

asked 1xhardGraphsOnline test2017

Ans. Use BFS on states, where a state is Tom’s cell and a bitmask of collected cheese, and stop when the mask contains all cheese and the cell is Jerry’s location. Treat 0 as blocked and 1 or 2 as walkable. Store parents to reconstruct the path. Time is O(rows × cols × 2^cheese).

Q. Describe how you would handle a situation where you have a different point of view than your manager.

asked 1xunknownConflict resolutionManagerial2015

Ans. Pick a real example where the disagreement mattered but stayed professional. Emphasise listening first, checking facts, explaining your reasoning clearly, and being open to your manager’s context. Interviewers listen for respect, judgement, courage, and whether you can commit to the final decision once it is made.

Showing 60 of 103 questions. Ranked by how often the same question came back across interviews.

Practise a Yatra.com-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does Yatra.com ask?

Candidate interviews most often cover DSA (59%) and CS fundamentals (34%).

How many rounds does Yatra.com interview have?

Candidate interviews show an average of 3.5 rounds per experience, with a typical sequence of Online test → Technical. Individual interview paths can vary.

Is the Yatra.com interview hard?

Among questions with a recorded difficulty, the mix is easy 43%, medium 52%, hard 5%.