Q. Bridge and torch puzzle
asked 1xmediumLogical reasoningTechnical2014
Ans. Send the two fastest together first: 1 and 2 cross, 1 returns. Send the two slowest together: 5 and 10 cross, 2 returns. Then 1 and 2 cross again. Total time is 2 + 1 + 10 + 2 + 2 = 17 minutes. This minimises costly return trips.
Q. Camel and Banana puzzle.
asked 1xmediumLogical reasoningTechnical2014
Ans. The maximum is 533⅓ bananas. Move in stages, reducing shuttle cost when stock drops below each 1000-banana load. With 3000 bananas, transport costs 5 bananas per kilometre until 2000 remain, so go 200 km. Then cost is 3 per kilometre until 1000 remain, so go 333⅓ km. The final 466⅔ km costs 466⅔ bananas.
Q. Design an elevator system.
asked 1xmediumSystem designTechnical2014
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. Design a corpus search engine.
asked 1xmediumSearch systemsTechnical2014
Ans. Build an inverted index over the corpus, mapping each normalised term to sorted posting lists of document IDs, positions and term statistics. Ingestion tokenises, stems, removes noise and writes immutable index segments that are periodically merged. Queries parse terms, intersect postings, score with BM25 or similar, then fetch snippets and metadata from document storage.
Q. Implement a priority queue in Java
asked 1xmediumHeapsTechnical2020
Ans. Implement it with a binary heap backed by an array or ArrayList, which is also how Java’s PriorityQueue works. Insert by adding at the end and bubbling up; remove by replacing the root with the last element and bubbling down. Peek is O(1), insert and remove are O(log n).
Q. How is security provided on a network?
asked 1xmediumNetworkingTechnical2014
Ans. Network security is provided by layered controls that protect confidentiality, integrity and availability. Common measures include user authentication, access control, encryption such as TLS or VPNs, firewalls, intrusion detection, network segmentation, logging and regular patching. The most important idea is defence in depth, so one failed control does not expose everything.
Q. Explain indexing in SQL and its advantages.
asked 1xmediumDBMSTechnical2021
Ans. Indexing in SQL is a way to speed up data retrieval by creating a separate data structure, usually a B-tree, on one or more columns. It lets the database find rows without scanning the whole table. The main advantage is faster queries, especially for WHERE, JOIN, ORDER BY, and GROUP BY, but indexes add storage and slow writes.
Q. Perform boundary traversal of a binary tree
asked 1xmediumTreesTechnical2015
Ans. Boundary traversal visits the root, the left boundary excluding leaves, all leaves from left to right, then the right boundary excluding leaves in reverse. Use recursion to collect leaves, a list for the left side, and a stack or reverse list for the right side. Time is O(n), with O(h) auxiliary space excluding output.
Q. How are user sessions maintained on the web?
asked 1xmediumNetworkingTechnical2014
Ans. User sessions are maintained by giving the browser a session identifier, usually in a cookie, and sending it with each request. The server uses that identifier to look up session data such as the logged-in user. Cookies should be secure, HTTP-only, same-site where appropriate, and expire after inactivity or logout.
Q. Explain the internal working of HashMap in Java
asked 1xmediumOOPTechnical2020
Ans. A HashMap stores key value pairs in an internal array of buckets, using the key’s hashCode to choose a bucket index. If multiple keys land in the same bucket, it compares keys with equals and stores collisions in a linked list or, after enough collisions, a tree. Resizing happens when the load factor threshold is crossed.
Q. How would you implement a Top 5 Friends feature?
asked 1xmediumDesignTechnical2014
Ans. Implement it as a ranked list per user, driven by an interaction score from messages, comments, tags, visits, and recency. On each event, update that friend pair’s score and maintain the user’s top five in a small sorted set or cache. Reads are then constant time, with periodic decay and privacy filtering.
Q. Three baskets puzzle involving apples and oranges
asked 1xmediumLogical reasoningTechnical2014
Ans. Draw one fruit from the basket labelled “mixed”. Since every label is wrong, that basket must contain only the fruit you draw. If it is an apple, it is the apple basket. The basket labelled “oranges” must then be mixed, so the basket labelled “apples” is oranges. Reverse apple and orange if needed.
Q. Solve the '100 doors in a row' problem with proof.
asked 1xmediumLogical reasoningTechnical2014
Ans. The doors left open are numbered 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100. Door n is toggled once for each divisor of n. Divisors usually pair up, giving an even number of toggles, so the door ends closed. Perfect squares have one unpaired divisor, their square root, so they are toggled odd times.
Q. Write an API to perform a GET operation on a table
asked 1xmediumApi designTechnical2020
Ans. Expose GET /tables/{tableName}/rows/{id} to return one row by primary key, and GET /tables/{tableName}/rows with query parameters for filters, selected columns, sorting, limit and cursor. Validate table and column names against a schema whitelist, use parameterised queries, return JSON, and make pagination mandatory for large result sets.
Q. Explain paging in operating systems with an example
asked 1xmediumOperating systemsTechnical2014
Ans. Paging is a memory management technique where an operating system divides virtual memory into fixed-size pages and physical memory into same-size frames. A process sees continuous addresses, but pages can be stored in any free frames. For example, page 2 of a program may map to frame 7 in RAM.
Q. Explain the concept of zero trust in cybersecurity.
asked 1xmediumSecurityTechnical2024
Ans. Zero trust is a cybersecurity model that assumes no user, device, or network is trusted by default, even inside the organisation. Every access request must be verified continuously using identity, device health, context, and least privilege. The key idea is to reduce damage if an account or system is compromised.
Q. Reorder an array according to given index positions.
asked 1xmediumArraysTechnical2015
Ans. Place each element at the position specified by its corresponding index value. The simplest approach is to create a temporary array, set temp[index[i]] to arr[i] for each element, then copy it back. This uses an auxiliary array, runs in O(n) time, and needs O(n) extra space.
Q. Find the Lowest Common Ancestor (LCA) in a binary tree.
asked 1xmediumTreesTechnical2014
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. Compute the factorial of a very large number (e.g., 1000)
asked 1xmediumMathTechnical2018
Ans. Store the result as an array of digits and multiply it by each number from 2 to n, handling carries manually. For efficiency, use a larger base such as 10^9 per array element. The time complexity is roughly O(n times number of digits), and space is O(number of digits).
Q. How would you secure a network from common cyber threats?
asked 1xmediumNetworkingTechnical2024
Ans. I would use defence in depth: firewalls, secure configuration, regular patching, strong authentication, least privilege access, network segmentation, encryption, monitoring, and tested backups. The most important detail is reducing attack surface and limiting blast radius, so one compromised device or account cannot easily expose the whole network.
Q. Is HashMap concurrent and how is it related to Hashtable?
asked 1xmediumOOPTechnical2020
Ans. HashMap is not concurrent and is not thread safe for shared mutable use. Hashtable is the older synchronized hash table implementation, so its individual methods are thread safe but often slower and largely legacy. Both store key value pairs using hashing and implement Map. In modern code, use ConcurrentHashMap for concurrent access.
Q. Search for an element in a pivoted (rotated sorted) array.
asked 1xmediumBinary searchTechnical2014
Ans. Use modified binary search. At each step, compare the middle element with the left and right ends to find which half is sorted, then decide whether the target lies in that sorted half or the other half. No extra data structure is needed. Time complexity is O(log n), assuming distinct elements.
Q. Rotate a square matrix by 90 degrees using O(1) extra space.
asked 1xmediumArraysTechnical2014
Ans. Transpose the matrix in place, then reverse each row in place to rotate it 90 degrees clockwise. The key detail is that transposition swaps matrix[i][j] with matrix[j][i] only for one triangle, avoiding double swaps. This uses constant extra space and runs in O(n²) time for an n by n matrix.
Q. Explain operating system concepts such as mutexes and paging.
asked 1xmediumOperating systemsTechnical2014
Ans. Mutexes provide mutual exclusion so only one thread enters a critical section at a time, preventing race conditions. Paging is a memory management scheme that maps fixed-size virtual pages to physical frames, enabling isolation and efficient allocation. The key detail is that mutexes control concurrent access, while paging abstracts and protects memory.
Q. Print zig-zag (spiral) level order traversal of a binary tree.
asked 1xmediumTreesTechnical2015
Ans. Use level order traversal with a queue, processing one level at a time and alternating the print direction for each level. Store the current level’s values in a temporary list, reverse it when the direction is right to left, then print. Time complexity is O(n), and extra space is O(w), where w is tree width.
Q. How would you implement the Mutual Friends feature of Facebook?
asked 1xmediumDesignTechnical2014
Ans. Store each user’s friends as a sorted set or bitmap keyed by user id, then compute mutual friends by intersecting the two users’ friend lists. The key detail is choosing representation by scale: sorted lists for sparse graphs, bitmaps for very large lists, with caching for popular repeated queries.
Q. Perform zig-zag (spiral) level order traversal of a binary tree
asked 1xmediumTreesTechnical2018
Ans. Use breadth first search with a queue, processing the tree level by level and reversing the direction after each level. Store values for the current level in a list, append left to right or right to left depending on a flag, then flip it. Time complexity is O(n), space is O(n).
Q. Find the first non-repeating character in a stream of characters
asked 1xmediumStringsOnline test2015
Ans. Use a frequency map and a queue of candidate characters, updating both as each stream character arrives. Increment the character’s count, push it into the queue if first seen, then remove queue front items whose count is greater than one. The queue front is the current first non-repeating character. Each update is O(1) amortised time.
Q. Perform boundary traversal and zigzag traversal of a binary tree.
asked 1xmediumTreesTechnical2014
Ans. Boundary traversal prints root, left boundary excluding leaves, all leaves left to right, then right boundary excluding leaves in reverse. Zigzag traversal uses level order with a queue and reverses direction each level, or two stacks. Both visit each node once, so time is O(n); auxiliary space is O(h) for boundary recursion and O(w) for zigzag.
Q. Explain the time and space complexity of common sorting algorithms
asked 1xmediumSortingTechnical2020
Ans. Common sorting complexities are: bubble, selection and insertion sort are O(n²) time, with insertion best case O(n); merge sort is O(n log n) time and O(n) space; quicksort averages O(n log n) but can be O(n²); heap sort is O(n log n) and O(1) extra space. Stability and input order often matter.
Q. Discuss the pros and cons of monolithic architecture vs microservices
asked 1xmediumArchitectureSystem design2020
Ans. Monoliths are simpler to build, deploy and debug, while microservices give better independent scaling, ownership and release flexibility. The key trade-off is operational complexity: microservices add network calls, distributed failures, observability, data consistency and deployment coordination, so they usually pay off only when team size, scale or domain boundaries justify them.
Q. Given an N-ary tree, print the zig-zag (spiral) level order traversal
asked 1xmediumTreesOnline test2015
Ans. Use level order traversal with a queue, reversing the output direction on each level. For every level, process exactly the current queue size, collect node values in a temporary list, add children left to right to the queue, then print the list normally or reversed. Time is O(n), space is O(w).
Q. Given an array, print the Next Greater Element (NGE) for every element.
asked 1xmediumStacksTechnical2021
Ans. Use a stack to find the first greater element to the right of each array element. Traverse from right to left, popping values that are less than or equal to the current element. The stack top is the NGE if present, otherwise print -1. Push the current element. This runs in O(n) time.
Q. Puzzle: Find the average salary without disclosing individual salaries.
asked 1xmediumLogical reasoningTechnical2015
Ans. Each person can help compute a secure sum. One person chooses a private random number, adds their salary, and passes the total on. Each next person adds their salary only. The final total returns to the first person, who subtracts the random number. The result is total salary, divided by the number of people.
Q. Find the lexicographic rank of a given string among all its permutations
asked 1xmediumStringsTechnical2018
Ans. Compute the rank by scanning left to right and counting how many valid permutations start with a smaller character at the first differing position. Keep character frequencies, add factorial of remaining length adjusted by duplicate counts for each smaller available character, then fix the current character. This gives a 1-based rank in O(n times alphabet size) time.
Q. Which data structure is best suited for implementing a dictionary and why?
asked 1xmediumData structuresTechnical2015
Ans. A hash table is usually best suited for implementing a dictionary because it stores key-value pairs and supports fast lookup by key. With a good hash function, search, insert, and delete are average constant time. Collisions must be handled, but it is still the standard choice unless sorted order is required.
Q. How can you measure 45 minutes using two identical wires that burn unevenly?
asked 1xmediumLogical reasoningTechnical2020
Ans. Light the first wire at both ends and the second wire at one end at the same time. The first wire will burn out in 30 minutes, despite uneven burning. Then light the other end of the second wire. Its remaining burn time is 30 minutes, so both ends finish it in 15 more minutes. Total is 45 minutes.
Q. Name different CPU scheduling algorithms and which one do you think is best?
asked 1xmediumOperating systemsTechnical2018
Ans. Common CPU scheduling algorithms include First Come First Served, Shortest Job First, Shortest Remaining Time First, Priority Scheduling, Round Robin, and Multilevel Feedback Queue. There is no single best algorithm, but Multilevel Feedback Queue is often best for general-purpose systems because it balances responsiveness, fairness, and CPU utilisation across interactive and background jobs.
Q. Explain the dynamic programming formulation for a modified Rod Cutting problem
asked 1xmediumDynamic programmingTechnical2014
Ans. Define dp[i] as the maximum profit obtainable from a rod of length i. For each first cut length j, try price[j] plus the best value of the remaining length, so dp[i] = max(price[j] + dp[i-j]). If there is a cutting cost, subtract it only when a real cut is made. Time is O(n²).
Q. Explain database normalization and different normal forms (1NF, 2NF, 3NF, BCNF)
asked 1xmediumDBMSTechnical2014
Ans. Database normalization organises relational tables to reduce duplication and avoid update, insert, and delete anomalies. 1NF requires atomic values and no repeating groups. 2NF requires 1NF and no partial dependency on part of a composite key. 3NF removes transitive dependencies. BCNF is stricter: every determinant must be a candidate key.
Q. Generate all permutations of a string, both with and without duplicate characters
asked 1xmediumBacktrackingTechnical2015
Ans. Use backtracking to build permutations one character at a time, marking used characters or swapping in place. For duplicate-free strings, this generates n! permutations. For strings with duplicates, sort the characters and skip a character if it equals the previous unused one, or use a frequency map. Time is O(n × number of unique permutations).
Q. Dry run the Merge Sort algorithm on a given array and explain each step in detail.
asked 1xmediumSortingTechnical2021
Ans. Merge sort repeatedly splits the array, then merges sorted halves. For [38, 27, 43, 3, 9, 82, 10], split to single elements, then merge: [27,38], [3,43], [9,82], [10]. Merge again: [3,27,38,43] and [9,10,82]. Final merge gives [3,9,10,27,38,43,82]. Time complexity is O(n log n).
Q. Explain what happens when you type a URL like google.com in the browser address bar
asked 1xmediumNetworkingTechnical2024
Ans. The browser resolves google.com to an IP address using DNS, opens a TCP connection, usually negotiates TLS for HTTPS, sends an HTTP request, receives the response, and renders the page. The key detail is DNS lookup happens before connection, often using caches in the browser, OS, router, or resolver.
Q. Given an array of integers, find all pairs (a, b) such that (a % b) = K in O(N) time
asked 1xmediumArraysTechnical2014
Ans. You cannot guarantee O(N) time to list all pairs for arbitrary integers, because the output itself can be Θ(N²). For example, if K is 0 and all values are 1, every ordered pair matches. Use a frequency map, then for each a check divisors b of a minus K that exist.
Q. Design a stack that supports push, pop, and finding the maximum element in O(1) time.
asked 1xmediumStackTechnical2015
Ans. Use two stacks: one normal stack for values and one max stack tracking the current maximum. On push, add the value to the main stack and push either the new value or the previous maximum to the max stack. On pop, pop both stacks. The top of the max stack is the maximum in O(1).
Q. Explain Public Key (Asymmetric) Cryptography and describe how the RSA algorithm works.
asked 1xmediumSecurityTechnical2021
Ans. Public key cryptography uses a public key to encrypt or verify and a private key to decrypt or sign. RSA generates two large primes, multiplies them to form a modulus, and derives public and private exponents. Its security relies on factoring the modulus being infeasible. Encryption and signatures use modular exponentiation.
Q. Write code for Vertical Order Traversal of a Binary Tree considering all boundary cases
asked 1xmediumTreesTechnical2014
Ans. Use BFS with each node carrying a column index, starting root at 0, left as col minus 1 and right as col plus 1. Store values in a map from column to list, tracking minimum and maximum column. Return lists from min to max. Handle null root by returning empty. Time is O(n).
Q. Answer database questions involving inner joins and normalization based on given tables.
asked 1xmediumDBMSTechnical2014
Ans. Use an inner join to return only rows where the related keys match in both tables, typically a primary key to a foreign key. Normalisation means splitting data into well-structured tables to reduce duplication and update anomalies. The key detail is preserving relationships through keys while keeping each fact stored once.
Q. Implement the atoi() function and handle edge cases like overflow and invalid characters.
asked 1xmediumStringsTechnical2015
Ans. Parse the string left to right: skip leading spaces, read an optional sign, then accumulate digits until a non-digit appears. Use an integer accumulator and check before each multiply by 10 whether adding the next digit would exceed 32-bit bounds. Return INT_MAX or INT_MIN on overflow. Time is O(n), space is O(1).
Q. Print the preorder traversal of a binary tree given its inorder and postorder traversals.
asked 1xmediumTreesOnline test2015
Ans. Build the tree recursively, then print root, left, right. The last element of postorder is the root; find it in inorder to split left and right subtrees. Use a hash map from value to inorder index, and process postorder from the end. This gives O(n) time and O(n) space.
Q. Explain the KMP string matching algorithm and write code for its preprocessing (LPS array)
asked 1xmediumStringsTechnical2014
Ans. KMP matches a pattern in a text by avoiding rechecking characters, using an LPS array that stores the longest proper prefix of the pattern that is also a suffix. Preprocessing scans the pattern with two indices, updating an integer array. On mismatch, it falls back using previous LPS values. Preprocessing is O(m).
Q. Explain Python decorators and write functions using decorators with a detailed explanation.
asked 1xmediumOOPTechnical2021
Ans. Python decorators are functions that take another function, wrap it with extra behaviour, and return the wrapped function. Use them for logging, timing, authentication, or caching without changing the original function body. The wrapper usually stores the original function in a closure. Calling it adds constant overhead, so complexity remains that of the wrapped function.
Q. Given time as a string in the format HH:MM, draw an analog clock corresponding to the time.
asked 1xmediumImplementationTechnical2014
Ans. Parse HH:MM, convert it to hour and minute hand angles, then draw the clock face and two hands. The minute angle is minutes times 6 degrees, and the hour angle is hour mod 12 times 30 plus minutes times 0.5. Use trigonometry for hand endpoints. Time and space complexity are O(1).
Q. Check whether a given binary tree is a Binary Search Tree (BST). Provide multiple approaches.
asked 1xmediumTreesTechnical2014
Ans. Validate a BST by ensuring every node lies within an allowed value range: left values must be smaller and right values larger. Recursively pass lower and upper bounds, giving O(n) time and O(h) stack space. Another approach is inorder traversal and checking values are strictly increasing, also O(n). A bottom-up min/max check is another valid variant.
Q. What do you do when you're faced with a challenging problem that you don't know how to solve?
asked 1xmediumProblem solving2024
Ans. Choose a real example where the problem was unclear, high impact, and outside your existing knowledge. Emphasise how you broke it down, researched options, asked the right people, tested assumptions, and stayed calm. Interviewers listen for structured thinking, learning agility, ownership, collaboration, and knowing when to escalate rather than guessing.
Q. Explain how multiprocessing and event-driven programming work in Python in large-scale systems.
asked 1xmediumOperating systemsManagerial2021
Ans. Multiprocessing runs work in separate Python processes, while event-driven programming runs many non-blocking tasks on one or a few event loops. Multiprocessing suits CPU-bound work because it bypasses the GIL, but adds serialisation and IPC cost. Event-driven designs suit high-concurrency I/O, where throughput depends on avoiding blocking calls.
Q. Can you describe a time when you had to work with a difficult team member? How did you handle it?
asked 1xmediumTeamwork2024
Ans. Choose a real example where the issue affected work, not just personality. Emphasise how you stayed calm, listened, clarified expectations, adapted your communication, and kept the goal in focus. Show you addressed the problem directly and professionally. Interviewers listen for self-awareness, emotional control, accountability, and a constructive outcome.
Q. If you were advising the CEO of Serum Institute, one task is manufacturing a vaccine and another is distributing it globally. Who would you choose for each task—a scientist or an engineer—and why?
asked 1xmediumDecision makingManagerial2021
Ans. A strong answer would pick an engineer to lead manufacturing scale-up and global distribution, with scientists owning vaccine design, validation and quality standards. Emphasise that manufacturing is controlled, repeatable process design, while distribution is logistics, cold chain and systems optimisation. Interviewers listen for practical judgement, teamwork, and respect for scientific oversight.
Q. Design a notification system
asked 1xhardDistributed systemsSystem design2020
Ans. Design it as an event driven service: producers publish notification events to a queue, workers apply user preferences, render templates, and send through email, SMS, push, or in-app channels. The most important detail is reliable delivery: use durable queues, idempotency keys, retries with backoff, dead-letter queues, and delivery status tracking.
Q. Basic aptitude questions covering quantitative and logical reasoning (easy to moderate level)
asked 1xeasyLogical reasoningOnline test2021
Ans. Translate the question into simple maths or logic first. Identify what is given, what is asked, and any hidden constraints. Use formulas for percentages, ratios, averages, speed, time, and work where relevant. For reasoning, look for patterns, exclusions, and relationships. Check units, avoid assumptions, and verify the answer quickly.
Showing 60 of 143 questions. Ranked by how often the same question came back across interviews.