OLA Cabs interview questions

160 questions from 21 interviews · updated from reports 2015-2024

Practise OLA Cabs-style

About

Ola Cabs is an Indian ride-hailing platform that lets users book cabs, auto rickshaws, and other transport through its app. In India, it often hires for technical roles such as SDE-1, SDE-2, and Software Engineer.

The roles that come up most are SDE-2, SDE-1 and Software Engineer. This covers 21 candidate interviews reported from 2015 to 2024. Most sat it at entry level (11 of 20 that recorded a level), with 1 internship interviews alongside. Among the 4 that recorded either route, arrivals split between campus drives (1, 25%) and off-campus applications (3, 75%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Print the left view of a binary tree.

asked 4xeasyTreesTechnical2015-2017

Ans. Print the first node visible at each depth when the tree is viewed from the left. Do a level order traversal using a queue, and for each level print the first node removed from the queue. This visits every node once, so the time complexity is O(n), with O(w) space for the queue.

Q. Design an LRU (Least Recently Used) cache.

asked 2xmediumCache designSystem design2015

Ans. Use a hash map plus a doubly linked list to implement an LRU cache. The map gives O(1) access from key to node, and the list keeps usage order. On get or put, move the node to the front. When capacity is exceeded, remove the tail in O(1).

Q. Find the missing number in an arithmetic progression.

asked 2xeasyArraysTechnical2015

Ans. Use binary search to find the first position where the actual value differs from the expected arithmetic progression value. Compute the common difference from the first and last elements and the expected length. At index i, expected is first plus i times difference. The search takes O(log n) time and O(1) space.

Q. Explain how decision trees work.

asked 1xmediumMachine learningTechnical2016

Ans. Decision trees make predictions by asking a sequence of feature-based questions, moving from the root to a leaf that contains the final class or value. During training, the tree chooses splits that best separate the data, commonly using measures such as information gain, Gini impurity, or variance reduction.

Q. Implement the Minesweeper game logic.

asked 1xmediumMatrixOnline test2015

Ans. Use a 2D grid storing mine positions, revealed state, flags, and adjacent mine counts. On click, if it is a mine, end the game; if it has a positive count, reveal it; if it is zero, run BFS or DFS to reveal connected zero cells and their numbered borders. Each cell is processed once, so time is O(rows × cols).

Q. Explain Support Vector Machines (SVM).

asked 1xmediumMachine learningTechnical2016

Ans. Support Vector Machines are supervised learning models that classify data by finding the hyperplane that best separates classes with the largest margin. The key idea is that only the closest training points, called support vectors, determine the boundary. With kernels, SVMs can also handle non-linear separation by mapping data into higher-dimensional spaces.

Q. Count the number of inversions in an array.

asked 1xmediumSortingTechnical2017

Ans. Use a modified merge sort to count inversions in O(n log n) time. While merging two sorted halves, if an element from the right half is smaller than one from the left, it forms inversions with all remaining elements in the left half. Add that count, merge normally, and return the total.

Q. Find the next permutation of a given string

asked 1xmediumStringsTechnical2021

Ans. Scan the string from right to left to find the first character smaller than the character after it. Swap it with the smallest character greater than it on its right, then reverse the suffix after that position. This gives the next lexicographic permutation. If no such character exists, there is no higher permutation. Time is O(n).

Q. Generate all permutations of a given string.

asked 1xmediumBacktrackingTechnical2021

Ans. Use backtracking to build permutations one character at a time until the current string has the same length as the input. Keep a used boolean array to mark chosen characters, or swap characters in place. The key detail is duplicates: sort first and skip repeated unused choices. Time complexity is O(n! × n).

Q. How does Garbage Collection work in Android?

asked 1xmediumOperating systemsTechnical2015

Ans. Garbage collection in Android automatically frees heap memory by finding objects that are no longer reachable from active roots such as thread stacks, static fields and JNI references. Modern Android uses ART with mostly concurrent, generational collection, so short-lived objects are collected efficiently while reducing pauses, though leaks still happen if references are retained.

Q. Implement an LRU (Least Recently Used) cache.

asked 1xmediumDesignTechnical2017

Ans. Use a hash map plus a doubly linked list. The map gives O(1) access to cache nodes by key, and the list keeps usage order, with most recent at the front and least recent at the back. On get or put, move the node to the front. When capacity is exceeded, remove the back node.

Q. How would you optimize a slow-running SQL query?

asked 1xmediumDBMSTechnical2024

Ans. I would first inspect the execution plan to find where time is being spent, then fix the biggest bottleneck. Common improvements include adding or adjusting indexes, avoiding full table scans, reducing returned rows, simplifying joins, and removing unnecessary sorting or aggregation. I would also check statistics, query parameters, and whether the schema supports the access pattern.

Q. Find the median from a running stream of numbers.

asked 1xmediumHeapsTechnical2017

Ans. Use two heaps: a max heap for the lower half and a min heap for the upper half. Insert each number into the correct heap, then rebalance so their sizes differ by at most one. The median is the larger heap’s top, or the average of both tops. Insertion is O(log n), median lookup is O(1).

Q. Merge K sorted arrays into a single sorted array.

asked 1xmediumArraysTechnical2022

Ans. Use a min-heap to repeatedly take the smallest current element from the k arrays and append it to the result. Store each heap entry as the value plus its array index and position, then push the next element from that array. For N total elements, time is O(N log k) and space is O(k).

Q. Explain the internal working of HashMap and hashing

asked 1xmediumOOPTechnical2015

Ans. A HashMap stores key value pairs in an array of buckets, using a hash of the key to choose the bucket index. On put or get, it computes the hash, finds the bucket, then uses equals to match the exact key. Collisions are handled by a list or tree, and resizing happens when load factor grows.

Q. Perform spiral (zigzag) traversal of a binary tree.

asked 1xmediumTreesTechnical2017

Ans. Use level order traversal with a queue, but alternate the order in which each level’s values are recorded. For each level, process all queued nodes, add children left then right, and write values either left to right or right to left. This takes O(n) time and O(w) space, where w is maximum width.

Q. Write full code to create a mirror of a binary tree

asked 1xmediumTreesTechnical2015

Ans. Create the mirror of a binary tree by recursively swapping the left and right child of every node. Use depth first traversal with the call stack as the data structure: if the node is null, return; otherwise swap its children, then mirror both subtrees. Time complexity is O(n), and space is O(h).

Q. Design a MapReduce job to sort a very large dataset.

asked 1xmediumDistributed systemsTechnical2016

Ans. Use MapReduce with the sort key as the map output key, a total-order range partitioner, and reducers that write sorted partitions. First sample the data to choose balanced key ranges, then each mapper emits key-record pairs, shuffle sorts within each reducer, and concatenating reducer outputs in partition order gives one globally sorted dataset.

Q. Find the number of islands in a given binary matrix.

asked 1xmediumGraphsTechnical2015

Ans. Scan every cell and start a DFS or BFS whenever you find an unvisited 1, incrementing the island count once for that traversal. Mark all connected 1s as visited, usually using four directions unless diagonal connectivity is specified. The time complexity is O(rows × columns), with O(rows × columns) worst-case space.

Q. Implement LRU cache using a language of your choice.

asked 1xmediumDesignTechnical2015

Ans. Implement an LRU cache with a hash map plus a doubly linked list. The map gives O(1) access from key to node, while the list stores usage order. On get or put, move the node to the front. When capacity is exceeded, remove the tail node. Both operations are O(1).

Q. Explain heap implementation and its time complexities

asked 1xmediumHeapsTechnical2015

Ans. A heap is usually implemented as an array representing a complete binary tree, most often a min heap or max heap. For index i, children are at 2i + 1 and 2i + 2. Peek is O(1), insert is O(log n), delete root is O(log n), and build heap is O(n).

Q. Explain the Circuit Breaker pattern and its use cases

asked 1xmediumDistributed systemsManagerial2021

Ans. The Circuit Breaker pattern stops repeated calls to a failing dependency by opening the circuit after too many errors or timeouts. While open, calls fail fast or use a fallback, protecting threads, queues and users. After a delay it allows limited trial calls. It is used for remote services, databases, APIs and message brokers.

Q. What are different approaches to unsupervised learning?

asked 1xmediumMachine learningTechnical2016

Ans. Common approaches to unsupervised learning include clustering, dimensionality reduction, density estimation, association rule mining, and anomaly detection. Clustering groups similar data points, dimensionality reduction finds simpler representations, density estimation models the data distribution, association rules find co-occurring patterns, and anomaly detection identifies unusual examples without labelled outcomes.

Q. How can the UI of Fragment B be updated from Fragment A?

asked 1xmediumAndroidTechnical2015

Ans. Update Fragment B by sharing state through the hosting Activity, preferably with an activity scoped ViewModel. Fragment A writes the new data into LiveData or StateFlow in the shared ViewModel, and Fragment B observes it and refreshes its UI when it changes. For one-off messages, the Fragment Result API is also suitable.

Q. How would you handle tail queries in a large-scale system?

asked 1xmediumScalabilitySystem design2016

Ans. I would serve tail queries from an append-only, time-partitioned store with a small hot cache for the newest records. Writes go to ordered partitions, and reads ask the latest partition first, then page backwards if needed. The key detail is keeping the tail in memory or SSD-backed cache to avoid scanning cold data.

Q. How would you mock Couchbase while writing unit test cases?

asked 1xmediumTestingTechnical2016

Ans. Mock Couchbase by wrapping its SDK calls behind a repository or gateway interface, then mock that interface in unit tests using a framework such as Mockito. Return predefined documents, simulate misses and exceptions, and verify expected calls. Do not connect to a real cluster in unit tests; use Testcontainers or an embedded setup only for integration tests.

Q. How would you handle concurrency in the logging library design?

asked 1xmediumConcurrencyTechnical2015

Ans. I would make logging calls thread safe by pushing log events into a concurrent queue and having a dedicated background writer flush them to the sink. This keeps application threads fast and avoids multiple threads writing to the same file. The key detail is defining backpressure, such as blocking, dropping, or sampling when the queue is full.

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

asked 1xmediumTreesTechnical2016

Ans. Check it by traversing the tree recursively with an allowed value range for each node. The root can have an infinite range; the left child must be less than the node, and the right child greater. Use the call stack as the data structure. Time complexity is O(n), space is O(h).

Q. Explain different load balancing strategies and when to use them

asked 1xmediumScalabilityManagerial2021

Ans. Common load balancing strategies include round robin for equal servers, least connections for uneven request duration, weighted routing for different server capacities, IP hash for session affinity, and latency or health based routing for global or unreliable backends. The key detail is matching the algorithm to workload shape, server capacity, and failure handling needs.

Q. What are schedulers and how are they used in large-scale systems?

asked 1xmediumOperating systemsManagerial2021

Ans. Schedulers are components that decide when and where work runs. In large-scale systems, they assign tasks, jobs, or requests to available machines or threads based on capacity, priority, fairness, locality, and constraints. The key detail is that good scheduling improves utilisation and latency while preventing overload and starvation.

Q. Design an email system with tagging and sub-tagging functionality.

asked 1xmediumScalable systemsSystem design2017

Ans. Design it as an email store plus a tag service where emails, tags, and email tag mappings are separate tables, with tags supporting a parent tag id for sub-tags. The key detail is indexing: keep an inverted index from tag id to email ids, and use a materialised path or closure table to query all descendants efficiently.

Q. Explain common design patterns and related architectural concepts.

asked 1xmediumOOPManagerial2019

Ans. Common design patterns are reusable solutions to recurring design problems, such as Singleton, Factory, Strategy, Observer, Adapter and Decorator. They improve flexibility, testability and separation of concerns when used appropriately. Related architectural concepts include layering, MVC, dependency injection, microservices, event-driven design and clean architecture, which organise larger system structure and dependencies.

Q. Given a binary tree, print all the nodes visible from the top view.

asked 1xmediumTreesSystem design2017

Ans. Use level order traversal with a horizontal distance for each node, starting root at 0, left as -1 and right as +1. Store the first node seen at each horizontal distance in a map. A queue holds nodes with their distances. Finally print map values from smallest to largest distance. Time complexity is O(n log n).

Q. Given a node in a binary tree, find and print its inorder successor.

asked 1xmediumTreesSystem design2017

Ans. The inorder successor is the next node visited in inorder traversal. If the node has a right child, return the leftmost node in its right subtree. Otherwise, move up using parent pointers until you find an ancestor where the node lies in its left subtree. This takes O(h) time and O(1) space.

Q. Design and implement a Bowling Game with proper object-oriented design

asked 1xmediumOOPOnline test2015

Ans. Model the game with Game holding ten Frames, each Frame holding one or two rolls, and a final-frame subclass or rule allowing bonus rolls. Game exposes roll(pins) and score(). The key detail is scoring needs lookahead for strikes and spares, so store rolls sequentially or let frames access next rolls. Scoring is O(number of rolls).

Q. Boolean Matrix problem (modify the matrix based on boolean conditions).

asked 1xmediumArraysTechnical2015

Ans. Set every row and column containing a 1 to all 1s. First scan the matrix and store which rows and columns contain a 1 using two boolean arrays. Then scan again and update any cell whose row or column is marked. This takes O(RC) time and O(R + C) extra space.

Q. Describe the CI/CD pipeline and its importance in software development.

asked 1xmediumSoftware engineeringTechnical2024

Ans. A CI/CD pipeline automates building, testing, packaging and deploying software whenever changes are made. Continuous integration catches defects early by running checks on merged code, while continuous delivery or deployment makes releases repeatable and faster. Its main importance is reducing manual error and giving teams confidence to ship small changes safely.

Q. Given a matrix, if an element is 0, set its entire row and column to 0.

asked 1xmediumArraysTechnical2015

Ans. Use the first row and first column as markers to record which rows and columns must become zero. First check whether the first row or column originally contains zero, then mark zeros in the rest, apply the marks, and finally zero the first row or column if needed. Time is O(mn), space is O(1).

Q. Given a very large matrix, find the maximum connected region available.

asked 1xmediumGraphsTechnical2017

Ans. Scan the matrix and run an iterative DFS or BFS from each unvisited available cell, counting the size of that connected component and keeping the maximum. Use a visited bitset or boolean matrix and a stack or queue. Check all valid neighbours, usually 8 directions if diagonals count. Time is O(rows × columns).

Q. How would you handle uncertainties in Linear Discriminant Analysis (LDA)?

asked 1xmediumMachine learningSystem design2016

Ans. Handle uncertainties in LDA by treating predictions as posterior probabilities rather than hard labels, and by regularising the covariance estimate when data is noisy or limited. The key detail is shrinkage: combine the sample covariance with a simpler target matrix to reduce variance and avoid unstable decision boundaries.

Q. Print all nodes at a given distance K from a target node in a binary tree.

asked 1xmediumTreesTechnical2017

Ans. Build a parent map with one traversal, then run BFS from the target for K levels, visiting left child, right child and parent. Use a visited set to avoid going back to nodes already seen. When the BFS level reaches K, print all nodes in the queue. Time is O(n), space is O(n).

Q. How would you sort a very large file on a single machine with limited memory?

asked 1xmediumSortingTechnical2016

Ans. Use external merge sort: read the file in chunks that fit memory, sort each chunk in memory, write sorted runs to disk, then merge the runs. The key detail is a k-way merge using a min-heap holding one record from each run, so memory stays bounded and I/O is mostly sequential.

Q. Given a string, count the number of different substrings that are palindromes.

asked 1xmediumStringsOnline test2017

Ans. Use a palindromic tree, also called an Eertree, and return the number of palindrome nodes excluding the two artificial roots. Process characters left to right, following suffix links to find the longest extendable palindrome, then create a new node only if that distinct palindrome has not appeared before. This runs in O(n) time and O(n) space.

Q. Given an input stream of bits, check the occurrence of a given binary sequence.

asked 1xmediumStream processingSystem design2017

Ans. Use a finite state machine, equivalent to KMP, built from the target binary sequence. Maintain the length of the longest matched prefix as bits arrive. For each new bit, transition using the failure table; when the state reaches the pattern length, report an occurrence and fall back to allow overlaps. Processing is O(1) per bit.

Q. Find the square root of a number without using inbuilt functions in O(log N) time.

asked 1xmediumBinary searchTechnical2017

Ans. Use binary search on the answer range from 0 to N to find the integer square root in O(log N) time. At each step, take mid and compare mid with N divided by mid to avoid overflow. If mid squared is exact, return it; otherwise keep the best lower value as the floor square root.

Q. How does a hash table work? Describe its best-case and worst-case time complexity.

asked 1xmediumData structuresTechnical2024

Ans. A hash table stores key value pairs by using a hash function to map each key to an array index. In the best case, lookup, insert and delete are O(1). The main detail is collision handling, such as chaining or probing. In the worst case, many keys collide, making operations O(n).

Q. Implement string matching where the pattern string may contain wildcard characters.

asked 1xmediumStringsTechnical2015

Ans. Use dynamic programming where dp[i][j] says whether the first i characters of the text match the first j characters of the pattern. A normal character must match exactly, ? matches one character, and * matches empty or more characters. Use a boolean table, with space optimisable to one row. Time is O(nm).

Q. Discuss scalability considerations for different types of databases and caching layers

asked 1xmediumDatabasesManagerial2021

Ans. Relational databases scale best with good indexing, read replicas, partitioning, and careful transaction boundaries, while NoSQL systems often scale horizontally through sharding and replication but trade off joins or consistency. The key detail is access pattern: choose cache keys, invalidation, TTLs, and database partitioning around the highest-volume reads and writes.

Q. Design a search-based replacement for the existing Support tab navigation in the OLA app

asked 1xmediumApplication designSystem design2015

Ans. Build a Support search entry point that indexes FAQs, help flows, order and ride issue templates, and contact options, then returns ranked results with autocomplete and intent detection. The key detail is closing the loop with analytics: track queries, clicks, failures and escalations to improve ranking, synonyms and missing support content continuously.

Q. Design an application monitoring system to handle data coming from various applications.

asked 1xmediumMonitoring systemTechnical2015

Ans. Build agents or SDKs in each application to emit metrics, logs and traces into a central ingestion layer, then stream them through a queue to storage, alerting and dashboards. The key detail is to decouple ingestion from processing with Kafka or similar, so spikes do not drop data and consumers can scale independently.

Q. Given x, y, and k, find the maximum value of a XOR b equal to k such that x ≤ a < b ≤ y.

asked 1xmediumBit manipulationOnline test2017

Ans. The answer is k if a valid pair exists, otherwise no such value exists. For each a in the range, compute b = a XOR k and check x ≤ b ≤ y and a < b. This uses no extra data structure, runs in O(y - x + 1) time and O(1) space.

Q. Find the inorder predecessor and successor for a given key in a Binary Search Tree (BST).

asked 1xmediumTreesTechnical2015

Ans. Traverse the BST once, keeping two pointers: predecessor is the greatest value smaller than the key, and successor is the smallest value greater than the key. If the key is found, the predecessor may be the maximum node in its left subtree, and the successor may be the minimum node in its right subtree. Time is O(h), space is O(1).

Q. Generate all distinct permutations of a given string that may contain duplicate characters.

asked 1xmediumBacktrackingTechnical2021

Ans. Sort the string, then use backtracking with a used array to build permutations while skipping duplicate choices at the same recursion level. At each position, try each unused character, but if it equals the previous character and the previous copy was not used, skip it. Time is O(n! · n) in the worst case, with O(n) extra recursion space.

Q. Given a number, generate the next smallest permutation greater than the current permutation.

asked 1xmediumArraysTechnical2021

Ans. Scan the digits from right to left to find the first digit smaller than the digit after it. Swap it with the smallest digit greater than it on its right, then reverse the suffix to make it minimal. If no such digit exists, no greater permutation exists. This is O(n) time and O(1) extra space.

Q. Given one small file and one very large file, how would you find all numbers common to both?

asked 1xmediumHashingManagerial2021

Ans. Load all numbers from the small file into a hash set, then stream through the large file one number at a time and check whether each number is in the set. Output matches as they are found, or track emitted values to avoid duplicates. Time is linear in both files, memory is proportional to the small file.

Q. Design and implement an LRU Cache using Doubly Linked List and HashMap with given constraints

asked 1xmediumDesignOnline test2021

Ans. Use a HashMap from key to node and a doubly linked list ordered by recent use. The head holds the most recently used item and the tail the least. On get, return the value and move the node to head. On put, update or insert, then evict tail if capacity is exceeded. All operations are O(1).

Q. Represent the fraction of two integers as a string, handling repeating decimals appropriately.

asked 1xmediumMathTechnical2017

Ans. Divide the numerator by the denominator, append the integer part, then simulate long division for the decimal part. Store each remainder in a hash map with its position in the output. If a remainder repeats, insert parentheses at its first position. If it becomes zero, the decimal terminates. Time is O(k).

Q. Given two customers and two restaurants with preparation times and distances, determine the optimal delivery trajectory to minimize total delivery time.

asked 1xmediumOptimizationTechnical2017

Ans. Enumerate all feasible pickup and drop-off orders, then choose the one with the smallest completion time. A customer can only be delivered after their restaurant has been picked up, and a pickup may require waiting until food is ready. For each route, add travel time plus any waiting time. Without the actual times and distances, no unique trajectory can be determined.

Q. Puzzle: An employer has a gold bar of 7 units and must give 1 unit per day for 7 days. Using a magical knife that can only make two cuts total, how should the bar be cut?

asked 1xmediumLogical reasoningTechnical2015

Ans. Cut the bar into pieces of 1, 2, and 4 units, using cuts after the first unit and after the third unit. Pay by exchanging pieces: day 1 give 1, day 2 take back 1 and give 2, day 3 give 1, day 4 take back 1 and 2 and give 4, then continue similarly.

Q. How would you quickly start executing in a new technical area under time constraints?

asked 1xunknownLearning agilityTechnical2016

Ans. Pick a real example where you delivered before feeling fully expert. Emphasise how you identified the minimum knowledge needed, found reliable sources, asked focused questions, reduced risk with small tests, and communicated trade-offs. Interviewers listen for structure, learning speed, judgement, humility, and evidence that you can execute without waiting for perfect certainty.

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

Practise an OLA Cabs-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 OLA Cabs ask?

Candidate interviews most often cover DSA (55%) and CS fundamentals (28%).

How many rounds does OLA Cabs interview have?

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

Is the OLA Cabs interview hard?

Among questions with a recorded difficulty, the mix is easy 31%, medium 53%, hard 16%.