Swiggy interview questions

103 questions from 16 interviews · updated from reports 2015-2024

Practise Swiggy-style

About

Swiggy is an Indian online food ordering and delivery platform that also offers grocery delivery and related convenience services. In India, it commonly hires for technical roles such as SDE-1, SDE-2, and Associate Software Development Engineer for Android.

The roles that come up most are SDE-1, SDE-2 and Associate Software Development Engineer (Android). This covers 16 candidate interviews reported from 2015 to 2024. Most sat it at entry level (11 of 16 that recorded a level). Among the 9 that recorded either route, arrivals split between campus drives (3, 33%) and off-campus applications (6, 67%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Find the Lowest Common Ancestor (LCA) in a Binary Tree

asked 2xmediumTreesTechnical2020-2021

Ans. Use a recursive DFS: if the current node is null, p, or q, return it. Recurse into left and right. If both sides return non-null, the current node is the LCA. Otherwise return the non-null side. This uses the call stack and runs in O(n) time, with O(h) space.

Q. What is the Two-Phase Commit protocol?

asked 1xmediumDBMSManagerial2019

Ans. Two-Phase Commit is a distributed transaction protocol that ensures all participating systems either commit a transaction or all roll it back. In the prepare phase, a coordinator asks participants to vote. In the commit phase, it decides commit only if all vote yes. Its main weakness is blocking on coordinator failure.

Q. Check if a binary tree is a balanced BST

asked 1xmediumTreesOnline test2019

Ans. Use a postorder DFS that returns whether each subtree is a BST, whether it is height balanced, its height, and its minimum and maximum values. A node is valid if the left max is smaller, the right min is larger, and the two child heights differ by at most one. Time is O(n).

Q. Add two numbers represented as linked lists

asked 1xmediumLinked listsTechnical2021

Ans. Use a dummy head to build a result linked list while traversing both input lists digit by digit, adding corresponding values and a carry. Store sum modulo 10 as the new node value, and carry sum divided by 10 forward. Continue until both lists and carry are exhausted. Time is O(n), space is O(n).

Q. Find all Stepping Numbers within a given range

asked 1xmediumGraphsTechnical2021

Ans. Use BFS from digits 1 to 9, adding 0 separately if it lies in the range, and keep only values within the upper bound. Store candidates in a queue, extend each number using last digit plus or minus 1, collect values inside the range, then sort them. Time is O(k log k), space O(k).

Q. Write code to evaluate an arithmetic expression

asked 1xmediumStacksTechnical2015

Ans. Use two stacks: one for numbers and one for operators, scanning the expression left to right. Push numbers, handle opening brackets, and before pushing an operator, apply any operator on top with higher or equal precedence. Closing brackets trigger evaluation until the matching opening bracket. This runs in O(n) time and O(n) space.

Q. Why would you choose MongoDB over other databases?

asked 1xmediumDBMSManagerial2021

Ans. I would choose MongoDB when the application has document-shaped data, changing requirements, or needs fast development with a flexible schema. The main benefit is that related data can often be stored together in one document, reducing joins and making reads simple, while still supporting indexing, replication, and horizontal scaling.

Q. Design an online sports tournament management system

asked 1xmediumScalable systemsSystem design2019

Ans. Build a web platform with services for users, teams, tournaments, fixtures, scoring, standings, notifications and payments, backed by a relational database for strong consistency. The most important detail is modelling tournament formats cleanly, so knockout, league and group stages share core entities while scoring rules and progression logic remain configurable.

Q. Find the longest palindromic substring in a given string.

asked 1xmediumStringsTechnical2016

Ans. Use expand around centres: for each index, expand once for an odd-length palindrome and once between indices for an even-length palindrome, tracking the best start and length. The key detail is handling both centre types. This uses only a few variables, runs in O(n squared) time, and uses O(1) extra space.

Q. Find the next greater element for every element in an array

asked 1xmediumStacksTechnical2021

Ans. Use a decreasing monotonic stack to find the next greater element for each array value. Scan from right to left, popping values less than or equal to the current element. The stack top is the next greater element, or none if the stack is empty. Then push the current element. Time is O(n), space is O(n).

Q. Find the number of unique paths in a 2D grid with obstacles.

asked 1xmediumDynamic programmingTechnical2021

Ans. Use dynamic programming where each cell stores the number of ways to reach it, treating obstacle cells as zero. Start with 1 at the top-left if it is not blocked, then fill each cell from the top and left neighbours. The answer is the bottom-right value. Time is O(mn), space can be O(n).

Q. Search an element in a row-wise and column-wise sorted matrix

asked 1xmediumArraysTechnical2021

Ans. Start from the top-right element and eliminate one row or one column at a time. If the current value equals the target, return found. If it is greater, move left. If it is smaller, move down. This works because rows and columns are sorted. Time complexity is O(m + n), space is O(1).

Q. Given a string, print all subsets (subsequences) of the string

asked 1xmediumStringsOnline test2015

Ans. Use backtracking: for each character, make two choices, either include it in the current subsequence or skip it, and recurse to the next index. When the index reaches the string length, print the current subsequence. Use a temporary string or character list. There are 2^n subsequences, with O(n) recursion space.

Q. Print all the nodes visible from the top view of a binary tree.

asked 1xmediumTreesTechnical2021

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. Find all unique triplets in an array such that their sum is zero

asked 1xmediumArraysTechnical2021

Ans. Sort the array, then fix one number and use two pointers on the remaining range to find pairs that sum to its negative. Skip duplicate fixed values and duplicate pointer values after each match to keep triplets unique. This uses the sorted array in place, runs in O(n squared) time, and O(1) extra space excluding output.

Q. Construct a binary tree from preorder and inorder traversal arrays

asked 1xmediumTreesTechnical2021

Ans. Take the next preorder value as the root, find its position in inorder, then recursively build the left subtree from the left inorder range and the right subtree from the right range. Use a hash map from value to inorder index and a moving preorder pointer. This gives O(n) time and O(n) space.

Q. Given 4 processes and 4 resources, determine if deadlock can occur

asked 1xmediumOperating systemsTechnical2015

Ans. Yes, deadlock can occur with 4 processes and 4 resources, but the counts alone do not prove it. For example, if each process holds one resource and waits for the next resource in a cycle, no process can continue. The key detail is a circular wait with resources held non-preemptively.

Q. Find the total number of possible Binary Search Trees for a given N

asked 1xmediumDynamic programmingTechnical2021

Ans. The total number of possible Binary Search Trees with N distinct keys is the Nth Catalan number. It is C(N) = (2N)! / ((N + 1)! N!). Equivalently, use DP where dp[n] = sum of dp[i] * dp[n - 1 - i] for each root. Time complexity is O(N²).

Q. Compare O(2^n) and O(n!) time complexities and prove which is better

asked 1xmediumComplexityTechnical2015

Ans. O(2^n) is asymptotically better than O(n!) because n! grows faster. To prove it, compare n! / 2^n. This equals (1/2)(2/2)(3/2)...(n/2). From n = 4 onward, most factors are greater than 1, and the product grows without bound, so n! dominates 2^n.

Q. Count the number of binary strings of length N without consecutive 1s.

asked 1xmediumDynamic programmingTechnical2021

Ans. The number is Fibonacci(N + 2), using Fibonacci values F0 = 0 and F1 = 1. The key idea is that a valid string of length N either ends in 0, after any valid length N - 1 string, or ends in 10, after any valid length N - 2 string. This gives O(N) time and O(1) space.

Q. Given an infinite stream of numbers, find the median at each insertion

asked 1xmediumHeapsTechnical2015

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 top of the larger heap, or the average of both tops. Insertion is O(log n).

Q. Design a stack that supports getMin() in O(1) time and O(1) extra space

asked 1xmediumStackTechnical2021

Ans. Use one stack plus a variable currentMin. When pushing a value smaller than currentMin, store an encoded value such as 2*x - currentMin and update currentMin to x. When popping an encoded value, restore the previous minimum as 2*currentMin - encoded. Push, pop, top and getMin are all O(1).

Q. Find an element in a sorted array that has been rotated any number of times

asked 1xmediumBinary searchTechnical2015

Ans. Use a modified binary search: at each step, one half of the rotated sorted array is still sorted, so decide whether the target lies in that half and discard the other. This needs only index variables, so it uses constant space and runs in O(log n) time for distinct elements.

Q. Stock Buy Sell to Maximize Profit (maximize profit over given stock prices)

asked 1xmediumArraysOnline test2015

Ans. Use one pass, keeping the lowest price seen so far and the best profit possible if selling today. For each price, update the minimum buy price, then update maximum profit with price minus minimum. No extra data structure is needed. Time complexity is O(n), space complexity is O(1).

Q. Find the row with the maximum number of 1s in a row-wise sorted binary matrix

asked 1xmediumArraysTechnical2021

Ans. Start from the top-right cell and move left when you see a 1, otherwise move down; the last row where you moved left is the answer. Since each row is sorted, moving left finds more 1s, and moving down skips rows with fewer possible 1s. Time is O(rows + columns), space is O(1).

Q. Design a database schema for a food shop and optimize it for minimal complexity

asked 1xmediumDb designTechnical2015

Ans. Use four core tables: products, customers, orders, and order_items, with an optional categories table if reporting needs it. Products stores name, price, tax rate, stock, and active status. Orders stores customer, timestamp, and status. Order_items stores product, quantity, and price_at_sale. Add indexes on product name, order date, and foreign keys.

Q. Explain synchronization with an example of concurrent file access in write mode

asked 1xmediumOperating systemsTechnical2015

Ans. Synchronization is controlling access to a shared resource so only one thread or process modifies it at a time. For example, if two processes open the same file in write mode, a lock or mutex should guard writes so their data does not interleave, overwrite, or leave the file in an inconsistent state.

Q. What is the difference between concurrent programming and parallel programming?

asked 1xmediumConcurrencyManagerial2019

Ans. Concurrent programming is about structuring a program to handle multiple tasks in overlapping time periods, while parallel programming is about executing multiple tasks at the same time. Concurrency can happen on a single core through scheduling and context switching. Parallelism requires multiple cores, processors, or execution units to run work simultaneously.

Q. Count the minimum number of fountains to be activated to cover the entire garden

asked 1xmediumGreedyOnline test2021

Ans. Convert each fountain into a coverage interval and greedily choose the fewest intervals that extend coverage farthest. For fountain i, store the maximum right end for its left end. Scan the garden, maintaining current coverage and farthest reach; when current coverage ends, activate one fountain. This takes O(n) time and O(n) space.

Q. What are block ciphers and AES? Discuss security implications of Polybius Cipher

asked 1xmediumSecurityTechnical2015

Ans. Block ciphers encrypt fixed-size blocks of data using a symmetric key, and AES is the modern standard block cipher using 128-bit blocks and 128, 192, or 256-bit keys. AES is secure when used with proper modes and IVs. The Polybius Cipher is insecure because it is simple substitution, preserves patterns, and is easily broken by frequency analysis.

Q. Design and implement a Snake and Ladder game with extensible object-oriented design

asked 1xmediumObject oriented designSystem design2021

Ans. Model the game with Board, Cell, Jump, Snake, Ladder, Dice, Player and Game classes, where Game owns turn order and win rules. Store jumps in a map from start square to destination for O(1) lookup after each roll. Movement is O(1) per turn, and new jump types or dice rules can be added via interfaces.

Q. Which page replacement policy is used for swapping pages? Explain and implement LRU

asked 1xmediumOperating systemsTechnical2015

Ans. LRU, Least Recently Used, evicts the page that has not been accessed for the longest time. It works on the idea that recently used pages are likely to be used again. Implement it with a hash map from page to list node and a doubly linked list ordered by recency. Access and eviction are O(1).

Q. Rotate a given square matrix by 90 degrees clockwise and print the resulting matrix.

asked 1xmediumArraysOnline test2021

Ans. Rotate the matrix 90 degrees clockwise by first transposing it, then reversing each row. Transposing swaps matrix[i][j] with matrix[j][i], and reversing rows moves columns into their rotated positions. This can be done in place using the same 2D array, with O(n²) time and O(1) extra space.

Q. What are the differences between Node.js and Express.js for server-side development?

asked 1xmediumBackendManagerial2021

Ans. Node.js is the JavaScript runtime that lets you run server-side code, while Express.js is a web framework built on top of Node.js. Node provides core features like file access, networking and HTTP modules. Express simplifies routing, middleware, request handling and responses, making web APIs faster and cleaner to build.

Q. What data structure does a DNS server use and how does DNS search for an IP address?

asked 1xmediumNetworkingTechnical2015

Ans. A DNS server is part of a distributed hierarchical database, usually viewed as a tree of domain names. To find an IP address, a resolver checks its cache, then queries from the root servers to the TLD servers, then the authoritative server for the domain, which returns the A or AAAA record.

Q. Given a string containing '(', ')' and '*', check if it is a valid parenthesis string

asked 1xmediumGreedyTechnical2021

Ans. Use a greedy range of possible open brackets while scanning left to right. Keep low and high counts, where low treats '*' as ')' or empty, and high treats '*' as '('. If high ever goes below zero, return false. Clamp low to zero. At the end, valid if low is zero. Time is O(n), space is O(1).

Q. Given an array representing elevation map, compute how much rain water can be trapped

asked 1xmediumArraysOnline test2019

Ans. Use two pointers from both ends, keeping the maximum height seen on the left and right, and add trapped water based on the smaller side. If leftMax is less than rightMax, process the left side, otherwise process the right. This uses constant extra space and runs in O(n) time.

Q. Given a sorted array, count the frequency of all distinct numbers in less than O(n) time.

asked 1xmediumBinary searchTechnical2016

Ans. It is not possible in less than O(n) time in the worst case, because if all numbers are distinct, there are n frequencies to output. If the number of distinct values is small, you can jump through runs using binary search for the last occurrence, taking O(k log n) time for k distinct values.

Q. When should asynchronous programming be used versus synchronous programming in microservices?

asked 1xmediumSystem architectureManagerial2019

Ans. Use asynchronous programming when work is slow, independent, or can be completed later, such as messaging, events, notifications, or long-running tasks. Use synchronous programming when the caller needs an immediate result or strong request-response flow. The key trade-off is latency and coupling versus consistency, simplicity, and easier error handling.

Q. What are the differences between ReactJS and Vanilla JavaScript, and why would you prefer React?

asked 1xmediumWeb developmentManagerial2021

Ans. ReactJS is a UI library built on JavaScript, while Vanilla JavaScript is plain JavaScript without frameworks or libraries. React gives reusable components, declarative rendering, state management patterns, and efficient DOM updates through reconciliation. I would prefer React for larger, interactive applications because it improves structure, maintainability, and team productivity.

Q. Explain what happens in the background when a user types a URL like www.facebook.com in a browser

asked 1xmediumNetworkingTechnical2015

Ans. The browser resolves www.facebook.com to an IP address using DNS, then opens a connection to that server, usually with TCP and TLS for HTTPS. It sends an HTTP request, receives HTML, CSS, JavaScript and other resources, then parses and renders the page. Caching, redirects and CDNs may affect which server responds.

Q. Given gas and cost arrays, determine if you can complete the circuit and return the starting index

asked 1xmediumGreedyTechnical2021

Ans. Use a greedy scan: if total gas is less than total cost, return -1; otherwise a valid start exists. Track current tank and candidate start. For each station, add gas[i] minus cost[i]. If tank becomes negative, no station since the candidate can work, so set start to i + 1 and reset tank. Time is O(n), space O(1).

Q. Given an array, print all possible contiguous subarrays whose sum is divisible by a given number x.

asked 1xmediumArraysTechnical2015

Ans. Use prefix sums modulo x and store, for each remainder, all previous indices where it occurred. Start with remainder 0 at index -1. For each position, compute the current remainder; every previous index with the same remainder gives a subarray ending here whose sum is divisible by x. Use a hash map; time is O(n + output size).

Q. What are signal handlers in an operating system, and what happens when you run kill -9 on a process?

asked 1xmediumOperating systemsManagerial2019

Ans. Signal handlers are functions a process registers to run when it receives certain signals, such as SIGINT or SIGTERM. They let the process react, clean up, or exit gracefully. Running kill -9 sends SIGKILL, which cannot be caught, blocked, or handled, so the kernel terminates the process immediately and reclaims its resources.

Q. Explain the probability concepts behind Markov Chains and how state transition probabilities are computed.

asked 1xmediumProbabilityTechnical2024

Ans. A Markov Chain models a system moving between states where the next state depends only on the current state, not the full history. Transition probabilities are stored in a matrix, with each row summing to 1. They are computed from known rules or estimated as transition counts divided by total exits from a state.

Q. Design a Hotel Room Booking System using object-oriented principles. Define classes, methods, and entities.

asked 1xmediumOOPTechnical2021

Ans. Model it with Hotel, Room, Guest, Booking, Payment and InventoryService classes. Hotel owns rooms; Room has type, price and status; Booking links guest, room, dates and status. BookingService exposes searchAvailableRooms, createBooking, cancelBooking and checkIn. The key detail is preventing double booking by locking room availability per date range during booking confirmation.

Q. What are the important hyperparameters in Gradient Boosting Trees and how do they affect model performance?

asked 1xmediumMachine learningTechnical2024

Ans. Key hyperparameters are number of trees, learning rate, tree depth or leaf count, minimum samples per leaf, subsampling, column sampling and regularisation. More trees, deeper trees and weaker regularisation increase capacity but can overfit. A smaller learning rate usually improves generalisation, but needs more trees and more training time.

Q. How does Gradient Boosting Trees work, and how are residuals calculated at each iteration in a GBT classifier?

asked 1xmediumMachine learningTechnical2024

Ans. Gradient Boosting Trees builds an ensemble sequentially, where each new tree is trained to correct the current model’s errors. In a classifier, residuals are usually pseudo residuals: the negative gradient of the loss. For binary logistic loss, this is often y minus predicted probability, then predictions are updated with a learning rate.

Q. Given a sorted array where every element is repeated except one, find the non-repeated element in O(log n) time

asked 1xmediumBinary searchTechnical2015

Ans. Use binary search on pair alignment to find the single element in O(log n). In a correct left half, pairs start at even indexes. Make mid even, compare a[mid] with a[mid + 1]. If equal, the single element is to the right; otherwise it is at mid or to the left. Space is O(1).

Q. Design a medicine inventory system where an alarm is raised if the stock of any medicine goes below a threshold.

asked 1xmediumInventory systemManagerial2020

Ans. Use a central inventory service that stores each medicine’s current stock and threshold, and updates stock on purchase, sale, return, or expiry. After every stock-changing transaction, compare the new quantity with the threshold and publish an alert event if it is lower. Use database transactions or row locks to prevent missed alarms from concurrent updates.

Q. Given an infinite stream of integers arriving in a sorted manner, check if a given number is present in the stream

asked 1xmediumBinary searchTechnical2019

Ans. Read values from the stream until the current value is at least the target. If it equals the target, return true; if it becomes greater, return false, because later values cannot decrease. This uses no extra data structure, O(1) space, and O(k) time for k values read before deciding.

Q. There are multiple bags of coins with one bag having fake coins. Using a balance, determine the bag with fake coins

asked 1xmediumLogical reasoningTechnical2021

Ans. Divide the bags into three equal groups. Put one coin from each bag in group A on one pan, and one coin from each bag in group B on the other. If they balance, the fake bag is in group C. Otherwise, choose the lighter or heavier side, as known. Repeat until one bag remains.

Q. Given two sequences, find the maximum number of bridges that can be built without crossing (Building Bridges problem).

asked 1xmediumDynamic programmingTechnical2020

Ans. Sort the city pairs by one bank, then find the longest increasing subsequence of their positions on the other bank. That LIS length is the maximum number of non-crossing bridges. The key detail is tie handling: if two pairs share the same coordinate, order the other coordinate carefully to avoid choosing invalid bridges. Time complexity is O(n log n).

Q. Given packet sizes of 6, 9, and 20 pens, determine whether a given number N of pens can be sold if only full packets can be sold.

asked 1xmediumNumber theoryManagerial2020

Ans. Yes, N can be sold if it can be written as 6a + 9b + 20c for non-negative integers a, b, and c. Use a boolean dynamic programming array where dp[0] is true, and mark dp[i] true if dp[i - 6], dp[i - 9], or dp[i - 20] is true. Time and space are O(N).

Q. Given functional dependencies, how do you check whether the dependencies are valid by modeling them as a DAG and detecting cycles?

asked 1xmediumDBMSTechnical2021

Ans. Model each dependency as directed edges and the set is valid as a DAG only if cycle detection finds no directed cycle. Add a node per attribute or task, add edges from each determinant to each dependent, then run DFS with visiting states or Kahn’s topological sort. Time complexity is O(V + E).

Q. Given N lines defined by (x1, x2) intervals, find the point where the maximum number of lines intersect when drawing a vertical line.

asked 1xmediumArraysTechnical2021

Ans. Use a sweep line over the interval endpoints and find the x-coordinate where the maximum number of intervals overlap. Create events for each line: +1 at x1 and -1 at x2. Sort events by x, processing starts before ends for closed intervals. Track the running count and record the x with the highest count. Time is O(N log N).

Q. Given a server containing a 900MB file and a client machine with only 100MB available memory, how would you sort the file on the client?

asked 1xmediumSortingTechnical2015

Ans. Use external merge sort: stream the file in chunks smaller than 100MB, sort each chunk in memory, and write each sorted run to disk. Then perform a k-way merge of the runs using small input buffers and a min-heap. This needs only limited memory and runs in O(n log n) overall.

Q. Given ratings of programmers, pair them such that the sum of absolute differences in ratings (bias amount) across all pairs is minimized.

asked 1xmediumGreedyOnline test2021

Ans. Sort the ratings in ascending order and pair adjacent programmers. This minimises the total bias because, on a sorted line, crossing pairs can always be swapped to reduce or keep the same absolute difference sum. Use an array sort, then scan by twos and add differences. Time complexity is O(n log n), space depends on sorting.

Q. Design and implement an LRU (Least Recently Used) Cache, discussing suitable data structures and time complexities for different operations.

asked 1xmediumDesignTechnical2015

Ans. Use a hash map plus a doubly linked list to implement an LRU cache with O(1) get and put. The map stores keys to list nodes, and the list keeps usage order, with most recent at the front. On access, move the node to front. On overflow, remove the tail and delete its map entry.

Q. Given a function f6() that returns a random number from 1 to 6 with equal probability, implement f12() that returns a random number from 1 to 12 with equal probability.

asked 1xmediumProbabilityTechnical2020

Ans. Call f6() twice and combine the results into one number from 0 to 35: n = (f6() - 1) * 6 + (f6() - 1). Each value of n is equally likely. Since 36 is divisible by 12, return (n % 12) + 1. Each output then has exactly three equally likely cases.

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

Practise a Swiggy-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 Swiggy ask?

Candidate interviews most often cover DSA (56%) and CS fundamentals (31%).

How many rounds does Swiggy interview have?

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

Is the Swiggy interview hard?

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