Q. Search an element in a rotated sorted array.
asked 2xmediumBinary searchTechnical2020-2023
Ans. Use a modified binary search: compare the middle element with the ends to decide which half is sorted, then check whether the target lies inside that sorted half. If it does, search there, otherwise search the other half. For distinct elements, this takes O(log n) time and O(1) space.
Q. Print the left view of a binary tree.
asked 2xeasyTreesTechnical2019-2020
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. Explain the difference between HTTP and HTTPS.
asked 2xeasyNetworkingTechnical2018-2022
Ans. HTTP sends data between a browser and a server in plain text, while HTTPS uses TLS to encrypt that data. The important difference is security: HTTPS protects confidentiality, helps verify the server’s identity using certificates, and prevents tampering in transit. HTTP commonly uses port 80, and HTTPS uses port 443.
Q. Explain the difference between process and thread.
asked 2xeasyOperating systemsTechnical2021-2022
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. Design a TreeSet in Java.
asked 1xmediumOOPTechnical2015
Ans. Design it as a balanced binary search tree, typically a red black tree, storing only keys in sorted order. Insert, remove and contains compare keys using natural ordering or a Comparator, reject duplicates when comparison is zero, and rebalance after updates. Iteration is in-order. Core operations are O(log n).
Q. Sort words in a large file
asked 1xmediumSortingOnline test2014
Ans. Use external sorting: read chunks that fit in memory, sort the words in each chunk, write sorted runs to disk, then k-way merge the runs into the final sorted file. The key data structure is a min-heap holding one current word from each run. Time is O(n log n) overall, with disk I/O dominating.
Q. Explain SQL Injection attack
asked 1xmediumSecurityTechnical2014
Ans. SQL injection is an attack where malicious input is inserted into an SQL query so the database executes unintended commands. It can let an attacker read, change or delete data, bypass login checks, or damage the database. The most important defence is using parameterised queries, not string concatenation with user input.
Q. Detect a loop in a linked list
asked 1xmediumLinked listsOnline test2014
Ans. Use Floyd’s cycle detection with two pointers, slow and fast, starting at the head. Move slow one node at a time and fast two nodes at a time. If they ever meet, there is a loop. If fast reaches null, there is no loop. This runs in O(n) time and O(1) space.
Q. Design a meeting scheduler system.
asked 1xmediumLow level designTechnical2020
Ans. Build a service that stores users, calendars, meetings, attendees and availability, with APIs to create, update, cancel and search for meeting slots. The key detail is conflict prevention: keep calendar events indexed by user and time range, check overlaps transactionally when booking, and publish notifications asynchronously through email or push queues.
Q. Compare Flask and Django frameworks.
asked 1xmediumSoftware engineeringTechnical2018
Ans. Flask is a lightweight microframework, while Django is a full-featured web framework with more built-in structure. Flask gives more flexibility and is good for small services or custom architectures. Django includes ORM, authentication, admin, routing and security defaults, so it is often better for larger applications needing rapid, standardised development.
Q. Design a synchronous key-value store.
asked 1xmediumKey value storeOnline test2019
Ans. Use an in-memory hash map backed by a write-ahead log, with each put synchronously fsynced before acknowledgement. Reads hit memory, writes append to the log then update memory, and recovery replays the log. For availability, replicate to followers and acknowledge only after a quorum commits, giving linearizable reads from the leader.
Q. Explain the concept of external sorting
asked 1xmediumOperating systemsTechnical2014
Ans. External sorting is sorting data that is too large to fit in main memory, so it is processed using disk storage. The usual method is to read manageable chunks, sort each in memory, write sorted runs to disk, then merge those runs, often with a priority queue and buffered I/O to reduce disk access.
Q. How would you debug a production issue?
asked 1xmediumProblem solvingTechnical2019
Ans. Pick a real incident where you stayed calm, protected users, and found the cause systematically. Emphasise triage, logs and metrics, recent changes, rollback or mitigation, clear communication, and post-incident learning. Interviewers listen for structured thinking, ownership, collaboration, and judgement about when to escalate rather than heroic solo debugging.
Q. Rotate an array using O(1) extra space.
asked 1xmediumArraysTechnical2015
Ans. Use the reversal method: reduce k with k mod n, reverse the whole array, reverse the first k elements, then reverse the remaining n minus k elements. This rotates right by k in place using only constant extra space. The key detail is normalising k first. Time complexity is O(n).
Q. What are semaphores and race conditions?
asked 1xmediumOperating systemsTechnical2021
Ans. Semaphores are synchronisation primitives used to control access to shared resources, while race conditions are bugs where the result depends on the timing or ordering of concurrent operations. A semaphore maintains a count that threads acquire and release atomically, helping prevent multiple threads from entering a critical section unsafely.
Q. Why is process synchronization required?
asked 1xmediumOperating systemsTechnical2022
Ans. Process synchronization is required to ensure that concurrent processes access shared resources safely and produce correct, consistent results. Without it, two processes may update the same data at the same time, causing race conditions. Synchronization controls entry to critical sections so only the right process acts at the right time.
Q. Explain JavaScript prototype inheritance.
asked 1xmediumOOPTechnical2016
Ans. JavaScript prototype inheritance means objects can inherit properties and methods from another object through their prototype chain. When a property is accessed, JavaScript first checks the object itself, then its prototype, continuing up the chain until found or null is reached. Functions use a prototype object for instances created with new.
Q. Reverse a linked list in groups of size k.
asked 1xmediumLinked listsTechnical2017
Ans. Reverse each block of k nodes by rewiring next pointers, then connect the previous block’s tail to the new head of the reversed block. Use three pointers to reverse a block in place, and first check that k nodes remain if partial groups should stay unchanged. Time complexity is O(n), space complexity is O(1).
Q. Reverse a linked list in groups of size n.
asked 1xmediumLinked listsTechnical2014
Ans. Reverse each block of n nodes in place by first checking that a full block exists, then reversing its pointers and linking it back to the previous block. Use three pointers for reversal: previous, current, and next. Leave a final short block unchanged unless specified otherwise. Time is O(L), space is O(1).
Q. Count the number of inversions in an array.
asked 1xmediumArraysOnline test2021
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. Generate all permutations of a given string
asked 1xmediumBacktrackingTechnical2022
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. Calculate a^b mod c using O(log n) approach.
asked 1xmediumMathOnline test2015
Ans. Use binary exponentiation: keep result as 1, reduce a modulo c, then repeatedly square a and halve b. If the current bit of b is 1, multiply result by a modulo c. This computes a^b mod c in O(log b) time and O(1) space. Use wide integer types to avoid overflow.
Q. Explain internal working of HashMap in Java.
asked 1xmediumOOPTechnical2021
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. Perform topological sort of a directed graph
asked 1xmediumGraphsTechnical2023
Ans. Use Kahn’s algorithm: compute each vertex’s indegree, put all zero-indegree vertices in a queue, repeatedly remove one, add it to the ordering, and decrease the indegree of its outgoing neighbours. If a neighbour becomes zero, enqueue it. If the output contains fewer vertices than the graph, there is a cycle. Time is O(V + E).
Q. Detect a loop in a linked list and remove it.
asked 1xmediumLinked listsTechnical2015
Ans. Use Floyd’s slow and fast pointer method to detect the loop, then remove it by finding the node where the cycle starts and setting the previous node’s next pointer to null. After slow and fast meet, move one pointer to head and advance both one step at a time. Time is O(n), space is O(1).
Q. Explain B-Trees and their usage in databases.
asked 1xmediumDBMSTechnical2020
Ans. B-Trees are balanced multi-way search trees that keep keys sorted and allow search, insert and delete in logarithmic time. Databases use them mainly for indexes because each node holds many keys, matching disk or page sizes and reducing I/O. This makes range queries, ordered scans and point lookups efficient.
Q. Explain the internal working of RecyclerView.
asked 1xmediumAndroidTechnical2017
Ans. RecyclerView displays large lists by creating only enough item views for the visible screen and reusing them as the user scrolls. The Adapter creates ViewHolders and binds data, the LayoutManager positions them, and the Recycler keeps detached views in a cache or pool so they can be rebound instead of inflated again.
Q. Write code to print a matrix in spiral order.
asked 1xmediumArraysTechnical2015
Ans. Traverse the matrix layer by layer using four boundaries: top, bottom, left, and right. Print the top row, right column, bottom row, and left column, then move the boundaries inward. No extra data structure is needed apart from the output. Time complexity is O(mn), and space is O(1).
Q. Explain the internal implementation of HashMap.
asked 1xmediumJavaTechnical2017
Ans. A HashMap is implemented as an array of buckets, where a key’s hash code is transformed into an index to store the key value entry. If multiple keys map to the same bucket, collisions are handled using a linked list or, in modern Java, a balanced tree after a threshold. Resizing happens when the load factor is exceeded.
Q. Explain the concept of factorial of large numbers
asked 1xmediumMathTechnical2014
Ans. The factorial of a large number is the product of all positive integers up to that number, but the result quickly exceeds normal integer limits. To handle it, store digits in a BigInteger or an array and simulate multiplication digit by digit, carrying values. This takes about O(n times number of digits) time.
Q. Find the frequency of each word in a huge dataset
asked 1xmediumHashingTechnical2014
Ans. Use a hash map from word to count, reading the dataset as a stream and incrementing the count for each word. This is O(n) time and O(k) space, where k is unique words. If it is too large for memory, partition by hash or use MapReduce, then merge counts per partition.
Q. Merge two linked lists (both sorted and unsorted)
asked 1xmediumLinked listsTechnical2014
Ans. For two sorted linked lists, use two pointers and build the result by repeatedly taking the smaller current node, giving O(n + m) time and O(1) extra space if relinking nodes. For unsorted lists, merging usually means concatenating them; link the tail of the first list to the head of the second.
Q. Explain Framing, Flow Control, and ARQ techniques.
asked 1xmediumNetworkingTechnical2020
Ans. Framing, flow control, and ARQ are data link layer techniques for packaging data, regulating sender speed, and recovering from transmission errors. Framing splits a bit stream into identifiable frames using length fields or delimiters. Flow control prevents receiver buffer overflow, commonly with sliding windows. ARQ uses acknowledgements, timeouts, and retransmission, such as Stop-and-Wait, Go-Back-N, and Selective Repeat.
Q. Explain SQL joins and how they work with examples.
asked 1xmediumSQLTechnical2021
Ans. SQL joins combine rows from two tables using a related column, such as customer_id in Customers and Orders. An INNER JOIN returns only matching rows. A LEFT JOIN returns all left table rows plus matches, with nulls when missing. RIGHT JOIN is the reverse. FULL JOIN returns all rows from both sides.
Q. Explain the concept of multithreading and threads.
asked 1xmediumOperating systemsTechnical2018
Ans. Multithreading is running multiple threads within the same process so work can happen concurrently. A thread is the smallest unit of execution, with its own call stack and program counter, while sharing the process’s memory and resources. This can improve responsiveness and throughput, but shared data needs synchronisation to avoid race conditions.
Q. Perform vertical order traversal of a binary tree.
asked 1xmediumTreesTechnical2014
Ans. Use BFS while assigning each node a column index, with root at 0, left child at column minus 1 and right child at column plus 1. Store values in a map from column to list. Finally output lists from smallest to largest column. Time is O(n log n) with an ordered map.
Q. Answer questions on Computer Networks fundamentals.
asked 1xmediumNetworkingOnline test2018
Ans. Computer networks fundamentals cover how devices communicate using protocols, addressing, routing, and layered design. The key detail is understanding the TCP/IP model: application protocols use transport services such as TCP or UDP, which rely on IP for addressing and routing packets across networks, with lower layers handling physical delivery.
Q. How would you implement swipe animation in Android?
asked 1xmediumAndroidTechnical2015
Ans. I would implement swipe animation using ViewPager2 for page-style swipes, or GestureDetector with ViewPropertyAnimator for a custom view. Track horizontal touch movement, translate the view with the finger, then animate it to the next position or back based on distance and velocity. The key detail is handling touch thresholds correctly.
Q. Print all cousins of a given node in a binary tree.
asked 1xmediumTreesTechnical2016
Ans. Use level order traversal and print all nodes at the same depth as the target node, except its siblings. Keep a queue of pairs containing each node and its parent. When the target is found on a level, scan that level and print nodes whose parent is different. Time complexity is O(n), space is O(w).
Q. What happens when you type a URL into your browser?
asked 1xmediumNetworkingTechnical2020
Ans. The browser resolves the domain to an IP address, connects to the server, requests the page, receives the response, and renders it. The key steps are DNS lookup, TCP connection, TLS handshake for HTTPS, HTTP request and response, then parsing HTML, fetching CSS and JavaScript, building the DOM and painting the page.
Q. What is JDBC connection pooling and why is it used?
asked 1xmediumDBMSTechnical2019
Ans. JDBC connection pooling is reusing a set of already opened database connections instead of creating a new connection for every request. It is used because opening connections is expensive, so pooling improves performance, reduces latency, controls database load, and manages connection lifecycle reliably in multi-user applications.
Q. Explain segment tree and analyze its time complexity
asked 1xmediumTreesTechnical2014
Ans. A segment tree is a binary tree data structure used to answer range queries, such as sum, minimum or maximum, and perform updates efficiently on an array. Each node stores information about a segment of the array. Building takes O(n), range query takes O(log n), update takes O(log n), and space is O(n).
Q. What happens when you search something on a browser?
asked 1xmediumNetworkingTechnical2022
Ans. The browser sends your query to the configured search engine, gets back an HTML results page, and renders it. Before that, it resolves the search engine’s domain using DNS, opens a connection, usually secures it with TLS, sends an HTTP request, then parses HTML, CSS and JavaScript to display the page.
Q. Explain the differences between B-Trees and B+ Trees.
asked 1xmediumDBMSTechnical2019
Ans. B-Trees store keys and records in both internal and leaf nodes, while B+ Trees store records only in leaf nodes and use internal nodes only for routing. The key practical difference is range access: B+ Tree leaves are usually linked, making scans faster and more consistent, which is why databases often prefer them.
Q. Perform iterative inorder traversal of a binary tree.
asked 1xmediumTreesTechnical2015
Ans. Use an explicit stack to simulate recursion: keep pushing current nodes while moving left, then pop a node, visit it, and move to its right child. Repeat while the stack is not empty or the current node is not null. This visits nodes in left, root, right order. Time is O(n), space is O(h).
Q. Find the number of islands in a 2D grid using DFS/BFS.
asked 1xmediumGraphsTechnical2020
Ans. Scan every cell, and when you find unvisited land, count one island and traverse all connected land using DFS or BFS. DFS uses recursion or a stack, while BFS uses a queue. Mark visited cells to avoid recounting. Check four directions unless diagonals are specified. Time is O(rows × cols), space is O(rows × cols).
Q. Perform iterative preorder traversal of a binary tree.
asked 1xmediumTreesTechnical2015
Ans. Use a stack to simulate recursion: push the root, then repeatedly pop a node, visit it, push its right child, then push its left child. Pushing right first ensures the left child is processed first. This gives preorder: root, left, right, in O(n) time and O(h) to O(n) space.
Q. Solve logical puzzles to test problem-solving approach
asked 1xmediumLogical reasoningTechnical2014
Ans. I would first restate the rules, identify fixed constraints, and test small cases to remove impossibilities. I would track assumptions clearly, then look for contradictions or invariants. If a unique answer emerges, I would explain why alternatives fail. If not, I would state what extra information is needed.
Q. Find the fastest 3 horses out of 25 with minimum races.
asked 1xmediumLogical reasoningHR2021
Ans. Minimum is 7 races. Race five groups of five. Race the five winners. The winner of that race is fastest. Only horses that could still be second or third are: second and third from the fastest winner’s group, first and second from the second fastest winner’s group, and first from the third fastest winner’s group. Race those five. Top two complete the top three.
Q. Find the maximum sum increasing subsequence in an array
asked 1xmediumDynamic programmingTechnical2024
Ans. Use dynamic programming where dp[i] is the maximum sum of an increasing subsequence ending at index i. Initialise dp[i] to arr[i], then for each earlier j, if arr[j] < arr[i], update dp[i] with dp[j] + arr[i]. The answer is the maximum value in dp. Time complexity is O(n²).
Q. How do you implement GCM push notifications in Android?
asked 1xmediumAndroidTechnical2015
Ans. Implement GCM by adding Google Play Services, declaring the required permissions and receiver or service, registering the app with the project sender ID, and sending the returned registration token to your server. The key detail is that the server uses that token to address notifications, while the app handles incoming messages in its GCM listener service.
Q. Maximum Separation (similar to Aggressive Cows problem)
asked 1xmediumBinary searchOnline test2023
Ans. Sort the positions, then binary search the answer, the maximum possible minimum separation. For each candidate distance, greedily place the first item at the earliest position, then place each next item at the earliest position at least that far away. If you can place all items, try larger. Time complexity is O(n log n + n log range).
Q. Estimate the approximate number of petrol pumps in India.
asked 1xmediumEstimationManagerial2015
Ans. Around 90,000 petrol pumps. Estimate it from demand: India uses roughly 5 million barrels of oil products daily, convert to petrol and diesel retail demand, then divide by average sales per pump. A simpler cross-check is population: 1.4 billion people, one pump per about 15,000 people, giving about 90,000 pumps.
Q. Find the contiguous subarray with maximum sum in an array
asked 1xmediumArraysOnline test2014
Ans. Use Kadane’s algorithm: scan the array, keeping the best subarray sum ending at the current index and the best sum seen overall. At each element, either extend the previous subarray or start a new one. It uses only a few variables, so time complexity is O(n) and space complexity is O(1).
Q. Find the longest palindromic substring in a given string.
asked 1xmediumStringsTechnical2019
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. Clone a linked list with next and arbitrary (random) pointer
asked 1xmediumLinked listsTechnical2021
Ans. Create a deep copy by mapping each original node to its cloned node, then set cloned next and random pointers using that map. Use a hash map from original node to copy node. First pass creates all copies, second pass wires pointers. Time complexity is O(n), space complexity is O(n).
Q. How would a platform like LinkedIn recommend people you may know?
asked 1xmediumRecommendation systemsTechnical2019
Ans. LinkedIn would recommend people by building a social graph and ranking likely connections from second-degree networks, shared workplaces, schools, locations, groups and contacts. The key detail is candidate generation before ranking: first find a small relevant set, then score it with machine learning while filtering blocked users, privacy settings and already connected profiles.
Q. How would you debug an issue when the source of input is not known?
asked 1xmediumProblem solvingTechnical2019
Ans. Pick a real incident where unclear inputs caused wrong behaviour, such as bad data, an API call, or user action. Emphasise tracing the flow from output backwards, adding logging, isolating components, checking assumptions, and reproducing safely. Interviewers listen for structured debugging, curiosity, evidence-based decisions, and avoiding blame or random changes.
Q. You have two ropes that each take 1 hour to burn. How do you measure 45 minutes?
asked 1xmediumLogical reasoningTechnical2015
Ans. Light the first rope at both ends and the second rope at one end. The first rope will finish in 30 minutes, whatever its uneven burn rate. At that moment, light the other end of the second rope. It has 30 minutes of burn left from one end, so both ends finish it in 15 minutes. Total: 45 minutes.
Q. Given a sequence of numbers, determine whether the sequence is Fibonacci, Arithmetic Progression, or Geometric Progression, and output the next term in the sequence.
asked 1xmediumLogical reasoningOnline test2015
Ans. Check the pattern using consecutive terms. If the difference between terms is constant, it is an arithmetic progression and the next term is last plus that difference. If the ratio is constant, it is a geometric progression and the next term is last times that ratio. Otherwise, check whether each term equals the sum of the previous two.
Showing 60 of 379 questions. Ranked by how often the same question came back across interviews.