Q. Have you worked in a team before?
asked 4xunknownTeamworkHR2020-2021
Ans. Choose a specific team example where your contribution mattered, ideally from work, study, volunteering, or a project. Emphasise your role, how you communicated, handled disagreement, supported others, and helped achieve the result. Interviewers listen for reliability, self-awareness, cooperation, and evidence that you can contribute without needing constant direction.
Q. What is thrashing in operating systems?
asked 3xmediumOperating systemsTechnical2015-2020
Ans. Thrashing is a state where an operating system spends most of its time swapping pages between memory and disk instead of executing processes. It usually happens when there is not enough physical memory for the active working sets, causing constant page faults, very low CPU utilisation, and poor overall performance.
Q. Best Time to Buy and Sell Stock with Cooldown
asked 3xmediumDynamic programmingTechnical2020-2021
Ans. Use dynamic programming with three states per day: holding a stock, just sold, and resting. Update each state from the previous day: hold by keeping or buying from rest, sold by selling held stock, rest by staying rested or cooling down after a sale. This uses constant space and runs in O(n) time.
Q. Find the median of a stream of running integers.
asked 3xmediumHeapsTechnical2020
Ans. Use two heaps: a max heap for the lower half of numbers and a min heap for the upper half. Insert each new 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. Insert is O(log n), median is O(1).
Q. Best Time to Buy and Sell Stock with Transaction Fee
asked 3xmediumDynamic programmingTechnical2020-2021
Ans. Use dynamic programming with two states: hold, the best profit while holding a stock, and cash, the best profit while holding none. For each price, update cash as max(cash, hold + price - fee) and hold as max(hold, cash - price). This uses constant space and runs in O(n) time.
Q. Find the Longest Common Subsequence (LCS) of three strings.
asked 3xmediumDynamic programmingOnline test2020
Ans. Use dynamic programming with a three dimensional table where dp[i][j][k] stores the LCS length of the first i, j, and k characters of the three strings. If the current characters match, add one to dp[i-1][j-1][k-1]; otherwise take the maximum of dropping one character from any string. Time and space are O(nmp).
Q. Best Time to Buy and Sell Stock IV
asked 3xhardDynamic programmingTechnical2020-2021
Ans. Use dynamic programming with buy and sell states for each transaction count. Keep two arrays of size k + 1, where buy[t] is the best profit after buying for transaction t, and sell[t] is after selling. Update them for each price. If k >= n / 2, use the unlimited-transactions greedy solution. Time is O(nk), space is O(k).
Q. Best Time to Buy and Sell Stock III
asked 3xhardDynamic programmingTechnical2020-2021
Ans. Use dynamic programming with four running states: best after first buy, first sell, second buy, and second sell. For each price, update these in order using the previous best values. The key detail is that the second buy uses profit from the first sell. This uses constant space and runs in O(n) time.
Q. Given an m x n grid, divide it into 4 parts by drawing one vertical and one horizontal line such that the total sum of absolute sums of all 4 parts is minimized.
asked 3xhardDynamic programmingOnline test, Technical2019
Ans. Use a 2D prefix sum, then try every possible horizontal cut and vertical cut, computing the four rectangle sums in O(1). For each pair, calculate |top-left| + |top-right| + |bottom-left| + |bottom-right| and keep the minimum. This takes O(mn) time after O(mn) preprocessing and O(mn) space.
Q. Given an m x n grid with integers, draw one vertical and one horizontal line to divide it into 4 parts such that the total sum of absolute sums of all 4 parts is minimized.
asked 3xhardArraysOnline test, Technical2019
Ans. Use a 2D prefix sum, then try every possible horizontal cut and vertical cut, computing the four rectangle sums in O(1) each and minimising |s1| + |s2| + |s3| + |s4|. The key detail is that cuts are usually between rows and columns, so iterate 1 to m-1 and 1 to n-1.
Q. Best Time to Buy and Sell Stock
asked 3xeasyDynamic programmingTechnical2020-2021
Ans. Track the lowest price seen so far and the best profit achievable at each day. For every price, treat it as a possible selling price, subtract the minimum earlier price, update the maximum profit, then update the minimum price. This uses only two variables, so time is linear and space is constant.
Q. Best Time to Buy and Sell Stock II
asked 3xeasyDynamic programmingTechnical2020-2021
Ans. Add every positive price difference between consecutive days to get the maximum profit. This works because unlimited transactions let you capture each upward movement as either separate trades or one combined trade. Use a running profit variable only. The time complexity is O(n), and the space complexity is O(1).
Q. What are the differences between C and C++?
asked 3xeasyOOPTechnical2015-2019
Ans. C is a procedural language, while C++ is largely a superset of C with object oriented and generic programming features. C++ adds classes, inheritance, polymorphism, templates, exceptions, references, function overloading and the standard library. The most important difference is abstraction: C gives low level control, while C++ supports higher level design without losing that control.
Q. Check whether a given string is a palindrome
asked 3xeasyStringsTechnical2015-2020
Ans. Use two pointers, one at the start of the string and one at the end, and compare characters while moving inward. If any pair differs, it is not a palindrome; if the pointers meet or cross, it is. This uses no extra data structure and runs in O(n) time with O(1) space.
Q. What is the difference between a process and a thread?
asked 3xeasyOperating systemsTechnical2015-2020
Ans. A process is an independent running program with its own memory space, while a thread is a smaller unit of execution within a process that shares that process’s memory. Processes are more isolated and cost more to create or switch between. Threads are lighter, but shared memory makes synchronisation and race conditions important.
Q. Explain ACID properties in DBMS
asked 2xmediumDBMSTechnical2020
Ans. ACID properties are the guarantees that make database transactions reliable: Atomicity, Consistency, Isolation and Durability. Atomicity means all or nothing, Consistency keeps valid rules, Isolation prevents concurrent transactions interfering, and Durability ensures committed changes survive crashes. They are essential for correctness in systems handling critical data.
Q. What are smart pointers in C++?
asked 2xmediumOOPSystem design, Technical2019
Ans. Smart pointers in C++ are objects that manage dynamically allocated memory automatically using RAII, so resources are released when the pointer object goes out of scope. The key types are std::unique_ptr for sole ownership, std::shared_ptr for shared ownership, and std::weak_ptr to observe shared objects without extending their lifetime.
Q. Policeman catches thieves problem
asked 2xmediumGreedyTechnical2020
Ans. Use a greedy two-pointer approach: store the indices of policemen and thieves, then scan both lists and match the current policeman with the current thief if their distance is at most k. If matched, move both pointers. Otherwise, move the pointer with the smaller index. This maximises catches in O(n) time.
Q. Puzzle: The Magnetic Rod problem.
asked 2xmediumLogical reasoningTechnical2019
Ans. Put the end of one rod against the middle of the other. Then swap the test. A magnet has its strongest attraction at its ends and little at its centre, while an iron rod is attracted by a magnet’s end. The test that gives strong attraction identifies the rod whose end is the magnet.
Q. Capacity to ship packages within D days
asked 2xmediumBinary searchTechnical2020-2021
Ans. Use binary search on the ship capacity, between the maximum single package weight and the sum of all weights. For each candidate capacity, greedily scan the packages in order and count how many days are needed. If days exceed D, increase capacity; otherwise try smaller. This uses no extra data structure and runs in O(n log sum).
Q. Explain how Garbage Collection works in Java.
asked 2xmediumOperating systemsTechnical2020
Ans. Garbage Collection in Java automatically reclaims heap memory used by objects that are no longer reachable from live references. The collector starts from GC roots such as stack variables, static fields and active threads, marks reachable objects, then frees or compacts the rest. Most collectors are generational, because short-lived objects are common.
Q. How do you create an immutable class in Java?
asked 2xmediumOOPSystem design, Technical2019
Ans. Create an immutable Java class by making the class final, making all fields private and final, setting them only in the constructor, and providing no setters. The key detail is to protect mutable fields: copy them on input and return defensive copies, so callers cannot change the object’s internal state.
Q. How is HashMap implemented internally in Java?
asked 2xmediumDBMSTechnical2020
Ans. Java HashMap is implemented as an array of buckets, where each bucket stores entries containing key, value, hash and next reference. The key’s hash is spread and mapped to an index. Collisions are handled by a linked list, or a balanced tree after enough entries. It resizes when the load factor threshold is exceeded.
Q. 309. Best Time to Buy and Sell Stock with Cooldown
asked 2xmediumDynamic programmingTechnical2020
Ans. Use dynamic programming with three states for each day: holding a stock, just sold, and resting or free to buy. Update them from the previous day, enforcing that buying can only follow a rest day, not a sale day. Keep only the last state values, giving O(n) time and O(1) space.
Q. Explain deadlock avoidance and prevention techniques.
asked 2xmediumOperating systemsTechnical2020
Ans. Deadlock prevention stops deadlock by ensuring at least one necessary condition can never hold, while deadlock avoidance only grants requests that keep the system in a safe state. Prevention may remove mutual exclusion, hold-and-wait, no pre-emption, or circular wait. Avoidance commonly uses Banker’s algorithm with declared maximum resource needs.
Q. Explain multithreading concepts in operating systems.
asked 2xmediumOperating systemsTechnical2020
Ans. Multithreading is the ability of a process to run multiple threads of execution that share the same memory and resources. Each thread has its own program counter, stack and registers. The key issue is safe coordination: shared data needs synchronisation, such as locks or semaphores, to avoid race conditions, deadlocks and inconsistent results.
Q. Explain memory management concepts in operating systems.
asked 2xmediumOperating systemsTechnical2020
Ans. Memory management is how an operating system allocates, tracks, protects and reclaims main memory for processes. Key concepts include virtual memory, paging, segmentation, address translation, swapping, fragmentation and protection. The most important idea is virtual memory, which gives each process its own address space while the OS maps it to physical RAM safely and efficiently.
Q. 714. Best Time to Buy and Sell Stock with Transaction Fee
asked 2xmediumDynamic programmingTechnical2020
Ans. Use dynamic programming with two states: hold is the best profit while owning a stock, and cash is the best profit while owning none. For each price, update cash by selling with the fee, and hold by buying from cash. Keep only two variables, so the time complexity is O(n) and space is O(1).
Q. Explain page replacement algorithms in operating systems.
asked 2xmediumOperating systemsTechnical2020
Ans. Page replacement algorithms decide which memory page to evict when physical memory is full and a new page must be loaded. Common algorithms include FIFO, LRU, Optimal, and Clock. The key goal is reducing page faults, because too many faults cause slow disk access and can lead to thrashing.
Q. Explain database normal forms and functional dependencies.
asked 2xmediumDBMSTechnical2020
Ans. Database normal forms are rules for structuring tables to reduce duplication and update anomalies, and functional dependencies describe how one set of attributes determines another. 1NF removes repeating groups, 2NF removes partial dependency on a composite key, 3NF removes transitive dependencies, and BCNF requires every determinant to be a candidate key.
Q. What happens if we execute: int arr[2]; while(true) arr++;
asked 2xmediumMemoryTechnical2020
Ans. It will not compile, because arr is an array name and cannot be incremented. In C and C++, an array expression may decay to a pointer in many contexts, but the array object itself is not a modifiable lvalue. If you used an int pointer instead, repeated increments beyond the array would cause undefined behaviour.
Q. Explain database normalization and its different normal forms.
asked 2xmediumDBMSTechnical2014-2024
Ans. Database normalization structures relational tables to reduce duplication and prevent update, insert, and delete anomalies. 1NF uses atomic values, 2NF removes partial dependency on a composite key, 3NF removes transitive dependency on non-key columns, and BCNF requires every determinant to be a candidate key. Higher forms handle multivalued and join dependencies.
Q. Given an array of n integers, you can divide the array into sections containing k elements each (n is divisible by k). The score of each section is the product of the elements in that section. Find the maximum possible sum of scores of all sections.
asked 2xmediumGreedyOnline test2021
Ans. For arbitrary integers, sorting alone is not always valid; the exact answer depends on whether reordering is allowed and on sign constraints. In the common non-negative version, sort descending, split into blocks of k, multiply each block, and sum. Pairing large values together maximises the total. Time complexity is O(n log n).
Q. Solve the N-Queens Problem using backtracking
asked 2xhardBacktrackingTechnical2016-2023
Ans. Place queens row by row, trying each column and backtracking whenever a placement conflicts with an existing queen. Track occupied columns and the two diagonals using sets or boolean arrays for O(1) safety checks. When all N rows are filled, record a solution. The worst-case time complexity is O(N!), with O(N) extra state excluding results.
Q. Conceptual questions on Operating Systems fundamentals.
asked 2xhardOperating systemsTechnical2020
Ans. Operating systems manage hardware resources and provide services for programs. The core ideas are processes and threads, CPU scheduling, memory management, file systems, system calls, synchronisation, deadlocks and I/O management. The most important detail is that the OS abstracts hardware while enforcing isolation, fairness and efficient resource sharing among running programs.
Q. Explain malloc and free in C.
asked 2xeasyMemoryTechnical2020
Ans. malloc allocates a requested number of bytes on the heap and returns a pointer to the start of that memory, or NULL if allocation fails. free releases memory previously allocated by malloc, calloc, or realloc. The key detail is ownership: each successful allocation should be freed exactly once, and not used afterwards.
Q. Explain CPU scheduling algorithms.
asked 2xeasyOperating systemsTechnical2020
Ans. CPU scheduling algorithms decide which ready process gets the CPU next. Common algorithms include First Come First Served, Shortest Job First, Round Robin, Priority Scheduling and Multilevel Queue. The key trade-off is between throughput, response time, waiting time and fairness, with pre-emptive algorithms allowing the OS to interrupt a running process.
Q. Explain operator overloading in C++.
asked 2xeasyOOPTechnical2019-2020
Ans. Operator overloading in C++ lets a class define how existing operators, such as +, ==, or [], work with its objects. It is implemented by writing special operator functions. The key point is that it should preserve intuitive meaning, and it cannot create new operators or change precedence or associativity.
Q. Explain the concept of virtual memory.
asked 2xeasyOperating systemsTechnical2020
Ans. Virtual memory is an operating system technique that gives each process the illusion of a large, private, continuous memory space. It maps virtual addresses to physical RAM using page tables. The key detail is paging: inactive pages can be kept on disk and loaded into RAM when needed, enabling isolation and efficient memory use.
Q. 122. Best Time to Buy and Sell Stock II
asked 2xeasyDynamic programmingTechnical2020
Ans. Use a greedy approach: add every positive price difference between consecutive days to the profit. This captures all upward movements, which is equivalent to buying before each rise and selling at its end. No extra data structure is needed. The time complexity is O(n) and the space complexity is O(1).
Q. Explain Inter Process Communication (IPC).
asked 2xeasyOperating systemsTechnical2020
Ans. Inter Process Communication is the set of operating system mechanisms that let separate processes exchange data and coordinate their actions. Common forms include pipes, message queues, shared memory, sockets and signals. The key issue is safe synchronisation, especially with shared memory, to avoid races, corruption and deadlocks.
Q. Object-Oriented Programming (OOP) concepts
asked 2xeasyOOPOnline test, Technical2019-2021
Ans. Object-Oriented Programming models software as objects that combine data and behaviour. The main concepts are encapsulation, which hides internal state; abstraction, which exposes only needed details; inheritance, which reuses and extends existing classes; and polymorphism, which lets different objects respond to the same interface in their own way.
Q. What are the necessary conditions for deadlock?
asked 2xeasyOperating systemsTechnical2020
Ans. The necessary conditions for a deadlock are mutual exclusion, hold and wait, no preemption, and circular wait. A resource must be non-shareable, processes must hold resources while waiting for others, resources cannot be forcibly taken, and a cycle of processes must each wait for the next. All four must hold simultaneously.
Q. Which data structure is used to implement an LRU Cache?
asked 2xeasyData structuresTechnical2021-2023
Ans. An LRU Cache is usually implemented with a hash map and a doubly linked list. The hash map gives O(1) access to cache entries, while the linked list keeps items in usage order. On access, move the item to the front; when full, remove the item at the tail.
Q. There are two traffic lights between your house and office. While going from house to office you stop twice, but while returning you stop only once. Traffic lights are always red when encountered. How is this possible?
asked 2xeasyLogical reasoningTechnical2021
Ans. It is possible only if the return journey is not the exact reverse route. Since every light you meet is red, each met light causes a stop. Going to the office you pass both lights, so you stop twice. Returning, you take a route that passes only one of those lights, so you stop once.
Q. Quantitative aptitude and logical reasoning questions.
asked 2xunknownLogical reasoningOnline test2020
Ans. Identify the question type first, then write down the given data clearly. Convert words into equations, ratios, tables, or diagrams as needed. Use shortcuts only when they are reliable. For reasoning, look for patterns, conditions, and eliminations. Check the final answer against the question to avoid calculation or interpretation errors.
Q. If you have a contradiction with your colleague, how will you resolve it?
asked 2xunknownConflict resolutionHR2020-2021
Ans. Pick a real disagreement where the issue mattered, not a personality clash. Emphasise listening first, clarifying facts, separating opinions from evidence, and agreeing on the shared goal. Show you stayed calm, involved others only when needed, and reached a practical outcome. Interviewers listen for maturity, respect, ownership, and collaboration.
Q. Policeman catches thieves
asked 1xmediumGreedyTechnical2020
Ans. Use a greedy scan to maximise catches: store indices of policemen and thieves separately, then match the earliest policeman with the earliest thief within distance k. If they can match, count it and move both pointers; otherwise move the one with the smaller index. This takes O(n) time and O(n) space.
Q. Compare B-Tree and B+ Tree.
asked 1xmediumDBMSTechnical2021
Ans. A B-Tree stores keys and records in both internal and leaf nodes, while a B+ Tree stores records only in leaf nodes and keeps internal nodes for routing. The key advantage of a B+ Tree is faster range queries, because leaf nodes are linked and scanned sequentially, making it common in database indexes.
Q. Explain K-means clustering.
asked 1xmediumMachine learningTechnical2018
Ans. K-means clustering is an unsupervised algorithm that groups data into K clusters by assigning each point to the nearest cluster centre. It starts with K initial centroids, repeatedly assigns points, then updates centroids as the mean of assigned points until stable. It minimises within-cluster squared distance.
Q. Find all bridges in a graph.
asked 1xmediumGraphsTechnical2020
Ans. Use Tarjan’s DFS algorithm on an undirected graph, tracking discovery time and the lowest reachable discovery time for each vertex. For every DFS tree edge u to v, if low[v] is greater than disc[u], that edge is a bridge. Store the graph as an adjacency list. Time complexity is O(V + E).
Q. Explain B-Trees and B+ Trees.
asked 1xmediumDBMSTechnical2015
Ans. B-Trees are balanced multiway search trees where each node stores several sorted keys and child pointers, keeping height small for disk or database access. B+ Trees are similar, but store actual records only in linked leaf nodes, with internal nodes used as indexes. This makes range scans faster and more predictable.
Q. Implement a Python list in C.
asked 1xmediumLinked listsTechnical2019
Ans. Implement it as a dynamic array holding pointers to objects, with fields for current length, allocated capacity and the pointer buffer. On append, grow capacity by over-allocating and copying pointers when full, giving amortised O(1) append. Indexing is O(1), insertion or deletion in the middle is O(n).
Q. Round Table Coin Game puzzle.
asked 1xmediumLogical reasoningTechnical2019
Ans. The first player wins by placing the first coin exactly at the centre of the round table. After that, whenever the second player places a coin, the first player places a matching coin at the point diametrically opposite. The circular table is symmetric, so that mirrored space must be legal if the opponent’s space was legal.
Q. Design an online reservation system for n rooms.
asked 1xmediumDesign2015
Ans. Use a central booking service with a rooms table, reservations table, and an availability index keyed by date range and room type. For each request, search available rooms, then create the reservation inside a database transaction using row-level locking or conditional writes. The key detail is preventing double booking under concurrent requests.
Q. Design an object-oriented system (OOP design question).
asked 1xmediumOOPTechnical2020
Ans. Start by identifying core entities, their responsibilities, and how they collaborate through clear interfaces. Model each class around one reason to change, keep state private, and use composition over inheritance where possible. Define main workflows, object lifecycles, and extension points, then validate the design against requirements, edge cases, and expected scale.
Q. Estimate the number of people playing football in India.
asked 1xmediumLogical reasoningHR2017
Ans. About 30 million people in India play football at least occasionally. I would estimate this by taking India’s population, narrowing it to a likely playing-age group, then applying an assumed participation rate. For example, 1.4 billion people, around 800 million in suitable age groups, and roughly 3 to 4 percent playing gives 25 to 35 million.
Q. Design a class structure to represent employees in an organization.
asked 1xmediumOOPTechnical2015
Ans. Use an Employee class with id, name, contact details, title, department, managerId, employment status, and compensation reference. Model reporting lines separately as relationships, not nested objects, so reorganisation is easy. Add subclasses only for genuinely different behaviour, such as Contractor or FullTimeEmployee, and use roles or permissions for job-specific differences.
Q. Quantitative aptitude questions based on probability, profit and loss
asked 1xmediumProbabilityOnline test2021
Ans. Use the basic formula first, then translate the wording carefully. For probability, count favourable outcomes and divide by total possible outcomes, adjusting for “and”, “or”, replacement, and independence. For profit and loss, use cost price, selling price, profit percentage, loss percentage, discount, and marked price formulas, keeping the base value clear.
Q. What all things should be tested on a checkout page of an e-commerce website?
asked 1xeasyLogical reasoningTechnical2021
Ans. A strong answer should group testing by user journey, payment, pricing, security, integrations, and edge cases. Emphasise cart accuracy, address validation, delivery options, discounts, taxes, failed payments, order confirmation, emails, responsiveness, accessibility, and performance. Interviewers listen for risk awareness, prioritisation, and understanding that checkout defects directly affect revenue and trust.
Showing 60 of 958 questions. Ranked by how often the same question came back across interviews.