Q. Check whether a given string of parentheses is balanced
asked 5xeasyStackOnline test, Technical2019-2024
Ans. Scan the string once and keep a counter of open parentheses. Increment it for each opening bracket and decrement it for each closing bracket. If the counter ever becomes negative, the string is not balanced. At the end, it is balanced only if the counter is zero. Time is O(n), space is O(1).
Q. Longest Substring Without Repeating Characters
asked 2xmediumStringsTechnical2024-2025
Ans. Use a sliding window with two pointers and a map from character to its last seen index. Move the right pointer through the string, and when a repeated character appears inside the current window, move the left pointer past its previous position. Track the maximum window length. Time complexity is O(n), space is O(min(n, charset)).
Q. Solve logical reasoning puzzles (aptitude section).
asked 2xmediumLogical reasoningOnline test2014-2018
Ans. Identify the puzzle type first, such as seating, order, blood relation, coding, or syllogism. List all given facts clearly, then convert them into a table, diagram, or symbols. Apply fixed conditions before uncertain ones. Eliminate impossible options step by step, check for contradictions, and verify the final answer against every clue.
Q. Find the next greater element for each element in an array
asked 2xmediumArraysTechnical2018-2025
Ans. Use a monotonic decreasing stack to find the next greater element for each array value in O(n) time. Traverse from right to left, popping values less than or equal to the current element. The stack top is then the next greater element, or -1 if the stack is empty. Push the current element afterwards.
Q. Given an array and a window size k, print the maximum element in each sliding window
asked 2xmediumArraysTechnical2016-2017
Ans. Use a double ended queue to store indices of useful elements, keeping values in decreasing order for the current window. For each element, remove indices outside the window from the front, remove smaller values from the back, add the current index, then the front is the maximum. This runs in O(n) time and O(k) space.
Q. Best Time to Buy and Sell Stock
asked 2xeasyArraysTechnical2024-2025
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. Convert a binary number to hexadecimal
asked 2xeasyBit manipulationTechnical2019
Ans. Group the binary digits into blocks of four from right to left, pad the leftmost block with leading zeros if needed, then replace each block with its hexadecimal digit. For code, scan the string in four-bit chunks using a lookup table or arithmetic conversion. The time complexity is O(n), with O(n) output space.
Q. Check whether a given string is a palindrome
asked 2xeasyStringsTechnical2021-2025
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. Reverse the order of words in a string using recursion.
asked 2xeasyRecursionTechnical2014-2016
Ans. Recursively reverse the words by taking the first word, reversing the rest of the string, then appending the first word at the end. Split the string into words first, or parse word boundaries during recursion. The key data structure is the call stack. Time complexity is O(n), with O(n) extra space.
Q. Given a column number, find its corresponding Excel column name
asked 2xeasyStringsTechnical2023-2024
Ans. Convert the number using a 1-indexed base 26 system, where A is 1 and Z is 26. Repeatedly subtract 1, take modulo 26 to get the next character, append it, then divide by 26. Reverse the built string at the end. Time complexity is O(log26 n), with O(log26 n) space.
Q. Replace every element in an array with the greatest element on its right side.
asked 2xeasyArraysOnline test, Technical2020
Ans. Traverse the array from right to left, keeping the greatest value seen so far, and replace each element with that stored value. After replacing, update the stored maximum using the original element. The last element becomes -1. This uses no extra data structure and runs in O(n) time.
Q. Sort List (Linked List)
asked 1xmediumLinked listsTechnical2024
Ans. Use merge sort, because linked lists can be split and merged without random access. Find the middle with slow and fast pointers, recursively sort both halves, then merge two sorted lists by relinking nodes. This takes O(n log n) time and O(log n) stack space, or O(1) extra space if done bottom-up.
Q. Top View of a Binary Tree
asked 1xmediumTreesTechnical2024
Ans. Use level order traversal with a horizontal distance for each node, root at 0, left child minus 1 and right child plus 1. Store the first node seen at each horizontal distance in a map, since BFS sees topmost nodes first. Finally output map values by increasing distance. Time is O(n log n), or O(n) with ordered handling.
Q. Merge overlapping intervals
asked 1xmediumArraysTechnical2024
Ans. Sort the intervals by start time, then scan once, keeping a result list of merged intervals. For each interval, compare its start with the end of the last interval in the result. If they overlap, extend the end; otherwise, append it. Time complexity is O(n log n) due to sorting, with O(n) space.
Q. Solve the puzzle: 1, 7, 26, ?
asked 1xmediumLogical reasoningTechnical2016
Ans. There is no unique answer; a common intended answer is 63. The likely pattern is “one less than consecutive cubes” after the first term: 2 cubed minus 1 is 7, and 3 cubed minus 1 is 26. Continuing gives 4 cubed minus 1, which is 63.
Q. Search in Rotated Sorted Array
asked 1xmediumBinary searchTechnical2024
Ans. Use modified binary search to find the target in a rotated sorted array in O(log n) time and O(1) space. At each step, one half is still sorted. Check whether the target lies inside that sorted half; if it does, search there, otherwise search the other half.
Q. Implement a Redis cache in Java
asked 1xmediumCachingTechnical2020
Ans. Use a Redis client such as Lettuce or Jedis, wrap it behind a Cache interface, and read from Redis before falling back to the database and writing the result back with a TTL. Store keys as namespaced strings and values as JSON or binary serialised objects. Reads and writes are average O(1).
Q. Recursive function behavior in C
asked 1xmediumCOnline test2019
Ans. A recursive function in C calls itself, creating a new stack frame for each call with its own parameters, local variables and return address. It continues until a base case stops further calls. Without a correct base case, recursion keeps consuming stack space and eventually causes stack overflow.
Q. Debugging questions in C and Java
asked 1xmediumProgrammingOnline test2020
Ans. I debug C and Java by first reproducing the issue, narrowing the failing path, and checking assumptions with logs, breakpoints, and tests. In C, I focus on memory errors, pointers, undefined behaviour, and tools like gdb or valgrind. In Java, I check exceptions, object state, threading, and JVM logs.
Q. Find the diameter of a binary tree.
asked 1xmediumTreesTechnical2020
Ans. Use a postorder DFS that returns the height of each subtree and updates a global maximum diameter at every node. For each node, the longest path through it is left height plus right height, measured in edges. Visit each node once, so the time complexity is O(n), with O(h) recursion stack space.
Q. Implement the flood fill algorithm.
asked 1xmediumGraphsTechnical2020
Ans. Use BFS or DFS from the starting cell, changing every connected cell with the original colour to the new colour. Keep a queue or stack, check four neighbours, and ignore cells out of bounds or with a different colour. If the colours are already equal, return immediately. Time is O(mn), space is O(mn).
Q. Evaluate an infix expression string.
asked 1xmediumStacksTechnical2024
Ans. Use two stacks: one for operands and one for operators. Scan left to right, push numbers, push opening brackets, and before pushing an operator, apply any stacked operators with higher or equal precedence. On a closing bracket, evaluate until the matching opening bracket. This runs in O(n) time and O(n) space.
Q. Print Pascal’s Triangle up to N rows
asked 1xmediumPatternsTechnical2017
Ans. Build each row from the previous row and print it as you go. Start with row [1]; for every next row, put 1 at both ends and fill each middle value as the sum of the two values above it. Use an array or list. Time complexity is O(N²), with O(N) extra space.
Q. Print a given matrix in spiral form.
asked 1xmediumArraysTechnical2024
Ans. Print the matrix by maintaining four boundaries: top, bottom, left and right. Traverse the top row, right column, bottom row and left column in order, shrinking the corresponding boundary after each pass. Continue while top is at most bottom and left is at most right. This visits each element once, so time is O(mn).
Q. What is paging in operating systems?
asked 1xmediumOperating systemsTechnical2024
Ans. Paging is a memory management technique where a process’s virtual address space is split into fixed-size pages, and physical memory is split into same-size frames. The OS maps pages to frames using a page table, allowing non-contiguous allocation. The key benefit is avoiding external fragmentation while supporting virtual memory.
Q. Explain multithreading concepts in Java.
asked 1xmediumOperating systemsTechnical2024
Ans. Multithreading in Java means running multiple threads within one process to perform tasks concurrently while sharing the same memory. Threads can be created with Thread, Runnable, Callable, or preferably managed through ExecutorService. The key concern is thread safety, handled using synchronised blocks, locks, volatile variables, concurrent collections, and careful coordination.
Q. Sort elements based on number of factors
asked 1xmediumSortingTechnical2024
Ans. Sort the elements by the count of their positive factors, usually in ascending order, and use the value itself as a tie-breaker if required. Precompute factor counts up to the maximum element using a sieve-style loop, store each number with its count, then sort with a custom comparator. Complexity is O(M log M + N log N).
Q. Find a given word in a 2D grid of letters
asked 1xmediumBacktrackingTechnical2019
Ans. Use depth first search with backtracking from every cell matching the first letter. At each step, move to valid neighbouring cells, usually up, down, left and right, marking the current cell as visited to avoid reuse, then unmark it on return. Time complexity is O(m n 4^k), where k is the word length.
Q. Find palindrome words in a given sentence
asked 1xmediumStringsTechnical2023
Ans. Split the sentence into words, normalise each word by lowercasing and removing punctuation, then check whether it reads the same forwards and backwards. Store matching words in a list. Use a two-pointer comparison for each word. The total time complexity is O(n), where n is the sentence length, and space is O(k).
Q. What is thrashing in an operating system?
asked 1xmediumOperating systemsTechnical2024
Ans. Thrashing is a state where an operating system spends most of its time swapping pages between RAM and disk instead of executing processes. It happens when memory demand is too high and processes suffer frequent page faults. The key effect is severe performance collapse, often fixed by reducing multiprogramming or adding memory.
Q. Implement a Binary Search Tree (BST) in C.
asked 1xmediumTreesTechnical2017
Ans. Implement a BST using a node structure containing an integer key and left and right child pointers. Insert by comparing the key and recursing or iterating left for smaller values and right for larger values. Search follows the same path. Deletion handles leaf, one-child, and two-child cases using the inorder successor. Operations are O(h), O(log n) if balanced.
Q. Reverse a linked list in groups of k nodes
asked 1xmediumLinked listsTechnical2020
Ans. Reverse each block of K nodes by iteratively flipping next pointers, then connect the previous block’s tail to the new head of the reversed block. First check that K nodes exist if the problem says incomplete groups stay unchanged. Use only pointer variables, so the time complexity is O(n) and extra space is O(1).
Q. Assign lifts based on capacity constraints.
asked 1xmediumConstraintsSystem design2017
Ans. Assign each request to the nearest lift that is travelling in the right direction and has enough remaining capacity, otherwise queue it until a suitable lift is available. Track each lift’s current floor, direction, planned stops, passenger count and max capacity. Recompute on every stop or new request to avoid overloading and reduce wait time.
Q. Explain tree and graph traversal techniques
asked 1xmediumGraphsTechnical2018
Ans. Tree and graph traversal means visiting every node in a systematic order, usually using depth-first search or breadth-first search. In trees, DFS appears as preorder, inorder, and postorder, while BFS is level order. In graphs, DFS uses a stack or recursion, BFS uses a queue, and both need a visited set to avoid cycles.
Q. Search an element in a rotated sorted array
asked 1xmediumBinary searchTechnical2024
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 reporting tree of a given employee
asked 1xmediumTreesTechnical2018
Ans. Build a manager-to-direct-reports map, find the given employee, then traverse and print each report with indentation by depth. Use a hash map from employee id to list of children, then run DFS or BFS from the target employee. This prints only their subtree in O(n) time and O(n) space.
Q. Solve aptitude problems based on probability
asked 1xmediumProbabilityOnline test2025
Ans. List all possible outcomes, then count the favourable outcomes and use probability equals favourable divided by total. Check whether events are independent, mutually exclusive, or conditional. Use addition for “or”, multiplication for “and”, and complements for “at least one”. For arrangements, use permutations or combinations before applying the probability formula.
Q. Explain how OAuth works and where it is used.
asked 1xmediumSecurityTechnical2024
Ans. OAuth is an authorisation framework that lets an application access a user’s resources without seeing their password. The user approves access with an authorisation server, which issues an access token to the application. It is used for delegated API access, such as allowing apps to read Google, Microsoft, GitHub or social media data.
Q. Find palindromic substrings in a given string
asked 1xmediumStringsTechnical2023
Ans. Expand around every possible centre and collect each substring while the characters on both sides match. Use two centre types, one for odd length and one for even length palindromes. Store results in a list, or a set if duplicates should be removed. This takes O(n squared) time and up to O(n squared) space.
Q. Find the top 3 duplicate elements in an array
asked 1xmediumArraysTechnical2024
Ans. Count frequencies with a hash map, then select the three values with the highest counts where count is greater than one. Since only three are needed, keep three best candidates while scanning the map instead of sorting everything. This is O(n) average time and O(m) space, where m is the number of distinct elements.
Q. How do you handle a node failure in Cassandra?
asked 1xmediumDistributed systemsTechnical2020
Ans. Cassandra handles a node failure by serving reads and writes from the remaining replicas, as long as the requested consistency level can still be met. The key detail is to restore replica consistency afterwards using hinted handoff for short outages, read repair, and scheduled repair, or replace and bootstrap the node if it is lost permanently.
Q. Solve logical puzzles given by the interviewer
asked 1xmediumLogical reasoningTechnical2023
Ans. I would first restate the rules, define the unknowns, and look for constraints that eliminate possibilities. I would test simple cases, keep track of assumptions, and check for contradictions. If one path fails, I backtrack and explain why. I would give the final answer only after verifying it satisfies every condition.
Q. Check whether a given number is a cyclic number
asked 1xmediumMathTechnical2015
Ans. Convert the number to a string s, let d be its length, and check every multiple n × i for i from 1 to d. Each product must have length d and must appear as a substring of s + s, meaning it is a rotation. This takes O(d²) time and O(d) space.
Q. Explain AWS IAM and its role in cloud security.
asked 1xmediumCloudTechnical2024
Ans. AWS IAM, Identity and Access Management, controls who can access AWS resources and what actions they can perform. It is central to cloud security because it enforces least privilege through users, groups, roles and policies. The most important practice is granting only the permissions needed, preferably using roles rather than long-lived access keys.
Q. Explain hashing techniques and their use cases.
asked 1xmediumDsa theoryTechnical2014
Ans. Hashing maps data to a fixed-size value so it can be stored, compared, or found quickly. Common techniques include separate chaining and open addressing to handle collisions. Hashing is used in hash tables, sets, caches, database indexes, duplicate detection, checksums, password storage, and load distribution, often giving average constant-time lookup.
Q. Explain how Garbage Collection works in Python.
asked 1xmediumProgramming languagesTechnical2020
Ans. Python mainly frees objects using reference counting: when an object’s reference count drops to zero, its memory can be reclaimed immediately. The key extra detail is that reference counting cannot handle reference cycles, so CPython also has a generational cyclic garbage collector that periodically detects and clears unreachable object groups.
Q. Explain techniques such as RESTful Web Services
asked 1xmediumNetworkingTechnical2023
Ans. RESTful web services expose resources over HTTP using standard methods such as GET, POST, PUT, PATCH and DELETE. Each resource is identified by a URI, and requests should be stateless, meaning all needed context is sent with each request. The key detail is using HTTP semantics correctly, including status codes and caching where appropriate.
Q. Group anagrams together from a list of strings.
asked 1xmediumStringsOnline test2023
Ans. Use a hash map where the key represents the letters of a word and the value is the list of words with that key. For each string, sort its characters to form the key, then append it to the matching group. This takes O(n k log k) time and O(n k) space.
Q. How do you delete a record in a Cassandra node?
asked 1xmediumDBMSTechnical2020
Ans. Delete a record in Cassandra by issuing a CQL DELETE for the row or columns, using the primary key to identify the data. Cassandra does not remove it immediately; it writes a tombstone marker. The actual data is discarded later during compaction, after the tombstone has been safely propagated to replicas.
Q. Solve aptitude problems based on time and speed
asked 1xmediumTime speedOnline test2025
Ans. Use the formula distance equals speed multiplied by time. Convert all units first, such as km/h to m/s by multiplying by 5/18. For relative speed, add speeds when moving opposite ways and subtract when moving the same way. For average speed, use total distance divided by total time.
Q. Count the number of islands in a 2D binary grid.
asked 1xmediumGraphsTechnical2024
Ans. Use DFS or BFS to scan the grid and count each unvisited land cell as the start of a new island. From that cell, traverse all connected land in four directions and mark it visited, so it is not counted again. The time complexity is O(rows × cols), with O(rows × cols) worst-case space.
Q. Explain how arrays work at the system level in C
asked 1xmediumCTechnical2018
Ans. In C, an array is a contiguous block of memory holding elements of the same type. The compiler knows the element size, so arr[i] is translated to an address calculation: base address plus i times element size. C does not store length with the array or check bounds, so invalid indexing can corrupt memory.
Q. Probability-based quantitative aptitude problems.
asked 1xmediumProbabilityOnline test2024
Ans. Identify the total number of equally likely outcomes and the number of favourable outcomes, then use probability equals favourable outcomes divided by total outcomes. For combined events, decide whether to add, multiply, or subtract overlap. Use complements for “at least one” cases, and conditional probability when information changes the sample space.
Q. Design and implement a Train Ticket Booking System.
asked 1xmediumLow level designTechnical2020
Ans. Build it with search, inventory, booking, payment and notification services over Train, Route, Trip, Coach, Seat and Booking entities. The key detail is preventing double booking: hold selected seats with a short TTL lock, confirm only after payment, then persist the booking transactionally. Use indexed trip-seat availability for fast searches.
Q. Handle a mock customer call and defend a sales pitch.
asked 1xmediumSales callManagerial2024
Ans. Choose a realistic call where the customer has a clear objection, such as price, trust, timing, or fit. Emphasise listening first, confirming the need, linking benefits to that need, and handling objections calmly. Interviewers listen for confidence, product understanding, empathy, commercial judgement, and whether you can defend value without sounding pushy.
Q. Solve logical puzzles to test problem-solving ability.
asked 1xmediumLogical reasoningTechnical2024
Ans. There is no specific puzzle to solve here, so the best answer is the method. I would restate the rules, list the known facts, identify constraints, and work through possibilities systematically. I would eliminate contradictions, check edge cases, and explain each step clearly before giving the final answer.
Q. Validate whether a binary tree is a Binary Search Tree
asked 1xmediumTreesTechnical2025
Ans. Validate it by traversing the tree with a valid value range for each node. Each node must be greater than its lower bound and less than its upper bound, then update the bounds for its children. Use recursion with the call stack. This visits each node once, so time is O(n) and space is O(h).
Q. How would you add more features to an existing project?
asked 1xmediumProblem solvingManagerial2020
Ans. Pick a real example where you improved an existing system without disrupting users. Emphasise how you understood current behaviour, checked priorities with stakeholders, assessed technical risk, designed changes that fitted the architecture, tested carefully, and released safely. Interviewers listen for product judgement, respect for legacy code, communication, and incremental delivery.
Q. Find the largest palindromic substring in a given string
asked 1xmediumStringsTechnical2018
Ans. Expand around every possible centre and keep the longest palindrome seen. For each index, check both odd length and even length centres, moving left and right while characters match. This uses constant extra space and runs in O(n²) time, which is usually acceptable unless Manacher’s O(n) algorithm is specifically required.
Q. Conduct a product demo based on given product information.
asked 1xmediumProduct demoManagerial2024
Ans. Choose a demo situation with a clear user, pain point, and success measure. Emphasise the product’s most relevant features, not every feature. Structure it around the customer journey: problem, workflow, outcome, and proof of value. Interviewers listen for clarity, prioritisation, product understanding, audience awareness, and confident handling of likely questions or objections.
Showing 60 of 746 questions. Ranked by how often the same question came back across interviews.