Q. Explain the difference between multithreading and multiprocessing.
asked 2xmediumOperating systemsTechnical2021
Ans. Multithreading runs multiple threads within one process, sharing the same memory space, while multiprocessing runs multiple separate processes, each with its own memory. Threads are lighter and useful for I/O-bound work, but shared state needs careful synchronisation. Processes have more overhead but give better isolation and can use multiple CPU cores more effectively.
Q. Given Q queries each with inputs L and R, find all composite numbers in the inclusive range [L, R].
asked 2xmediumNumber theoryOnline test2021
Ans. Precompute up to the maximum R using the Sieve of Eratosthenes, then answer each query by returning numbers in [L, R] that are greater than 1 and not prime. Store primality in a boolean array, or store composites in a sorted list. Preprocessing is O(maxR log log maxR); each query is O(k plus log maxR).
Q. Find common elements in three sorted arrays.
asked 2xeasyArraysOnline test2021
Ans. Use three pointers, one for each sorted array, and advance them to find values that are equal in all three. If all current values match, record the value and move all pointers, skipping duplicates if unique results are needed. Otherwise, advance the pointer with the smallest value. Time is linear in total length, space is constant excluding output.
Q. Explain the difference between JavaScript and TypeScript.
asked 2xeasyProgramming languagesTechnical2021
Ans. JavaScript is a runtime programming language, while TypeScript is a typed superset of JavaScript that compiles to JavaScript. TypeScript adds static types, interfaces, generics and better tooling, helping catch errors before execution. Browsers and Node.js run JavaScript, so TypeScript must be transpiled before it can run.
Q. Explain AVL trees and their operations
asked 1xmediumTreesTechnical2018
Ans. An AVL tree is a self-balancing binary search tree where, for every node, the heights of the left and right subtrees differ by at most one. Search works like a normal BST. Insert and delete update heights and rebalance using rotations. Search, insertion, and deletion all take O(log n) time.
Q. Print all permutations of a given string.
asked 1xmediumStringsOnline test2021
Ans. Use backtracking to build permutations by choosing each unused character in turn, recursing until the current string has the original length, then print it. Keep a character array, a boolean used array, and a temporary result buffer. The time complexity is O(n × n!) and the recursion depth is O(n).
Q. Explain inheritance and the Diamond Problem
asked 1xmediumOOPTechnical2017
Ans. Inheritance lets a class reuse and extend behaviour from another class, forming parent and child relationships. The Diamond Problem happens in multiple inheritance when a class inherits from two classes that both inherit from the same base, creating ambiguity about which base member is used. Languages handle it with virtual inheritance, interfaces, or method resolution rules.
Q. General data structures and algorithms questions
asked 1xmediumGeneralTechnical2020
Ans. Choose the data structure around the operations you need most, then explain the algorithm and its complexity clearly. For example, use a hash table for fast lookup, a heap for priority access, a stack for last-in first-out processing, or BFS and DFS for graph traversal. Always mention time and space complexity.
Q. Write the algorithm for Floyd-Warshall algorithm
asked 1xmediumGraphsOnline test2020
Ans. Floyd-Warshall computes all-pairs shortest paths by repeatedly allowing each vertex as an intermediate point. Initialise a distance matrix with edge weights, zero for the same vertex, and infinity where no edge exists. For each k, update dist[i][j] if dist[i][k] + dist[k][j] is smaller. Time is O(V³), space is O(V²).
Q. Write pseudocode for the Floyd Warshall Algorithm.
asked 1xmediumGraphsOnline test2020
Ans. Use a V by V distance matrix, initialise it with edge weights, 0 on the diagonal and infinity for missing edges, then for each intermediate vertex k update every pair i, j if dist[i][k] + dist[k][j] is smaller than dist[i][j]. The key detail is the k outer loop. Time is O(V³), space is O(V²).
Q. Convert a prefix expression to postfix using a stack
asked 1xmediumStackOnline test2022
Ans. Scan the prefix expression from right to left, using a stack of strings. Push operands onto the stack. When you see an operator, pop the first two strings, concatenate them as first operand, second operand, operator, then push the result back. The final stack value is postfix. Time complexity is O(n).
Q. What is a friend function and what is binding in C++?
asked 1xmediumOOPTechnical2021
Ans. A friend function in C++ is a non-member function that is allowed to access private and protected members of a class. It is declared with the friend keyword inside the class. Binding is the association of a function call with its definition, either at compile time as static binding or at runtime as dynamic binding using virtual functions.
Q. Solve and explain a coding problem related to strings.
asked 1xmediumStringsTechnical2025
Ans. Use a sliding window to find the longest substring without repeating characters. Keep two pointers for the current window and a hash set or map of seen characters. Move the right pointer to expand, and move the left pointer when a duplicate appears. This runs in linear time with linear extra space.
Q. Find the longest palindromic substring in a given string.
asked 1xmediumStringsOnline test2019
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. Explain how Hash Maps work and how collisions are handled.
asked 1xmediumHashingTechnical2021
Ans. A hash map stores key value pairs by hashing the key to choose an array index. If two keys map to the same index, collisions are usually handled by chaining with a list or bucket, or by open addressing to find another slot. Good hashing and resizing keep lookup, insert and delete average O(1).
Q. Write an algorithm for a problem using Dynamic Programming
asked 1xmediumDynamic programmingOnline test2020
Ans. Use dynamic programming by defining a state, writing a recurrence, setting base cases, and filling a table so each subproblem is solved once. For example, in 0/1 knapsack, let dp[i][w] be the best value using first i items and capacity w. Use a 2D array, with O(nW) time and space.
Q. What is Blockchain and what are its potential applications?
asked 1xmediumEmerging technologiesManagerial2021
Ans. Blockchain is a distributed, append-only ledger where transactions are grouped into blocks, cryptographically linked, and agreed by a network without a central authority. Its key value is tamper resistance and shared trust. Applications include cryptocurrencies, supply chain tracking, digital identity, smart contracts, audit logs, voting systems, and asset ownership records.
Q. Find the maximum size subarray with equal number of 0s and 1s.
asked 1xmediumArraysOnline test2019
Ans. Convert every 0 to -1, then find the longest subarray with sum 0. Keep a running prefix sum and store the first index where each sum appeared in a hash map. If the same sum appears again, the subarray between those indices is balanced. This takes O(n) time and O(n) space.
Q. Explain or write an algorithm for path finding using BFS or DFS
asked 1xmediumGraphsOnline test2022
Ans. Use BFS to find a path by starting at the source, visiting neighbours level by level with a queue, and storing each node’s parent to reconstruct the path when the target is found. Mark visited nodes to avoid cycles. BFS gives the shortest path in an unweighted graph, with time complexity O(V + E).
Q. Explain the Diamond Problem in Object-Oriented Programming (Java).
asked 1xmediumOOPTechnical2019
Ans. The Diamond Problem is an ambiguity that occurs when a class inherits the same method or state through two different parent paths. Java avoids it for classes by not allowing multiple class inheritance. With interfaces, if two default methods conflict, the implementing class must override the method and choose the behaviour explicitly.
Q. What is an RDBMS and what are some algorithms used in data mining?
asked 1xmediumDBMSTechnical2020
Ans. An RDBMS is a relational database management system that stores data in tables with rows and columns, using keys and SQL to define, query and manage relationships. Common data mining algorithms include decision trees, k-means clustering, k-nearest neighbours, Naive Bayes, association rule mining such as Apriori, and neural networks.
Q. Write the algorithm or logic for a given problem in your own words.
asked 1xmediumAlgorithmic thinkingOnline test2025
Ans. I would first define the input, output and constraints, then describe the steps needed to transform the input into the output. I would choose the right data structure, explain the main loop or recursion, handle edge cases, and state the time and space complexity. I would keep the logic simple and unambiguous.
Q. Explain the algorithm or pseudocode to solve a problem using backtracking.
asked 1xmediumBacktrackingOnline test2021
Ans. Use a recursive function that builds a partial solution, tries each valid choice, recurses, then undoes the choice before trying the next one. Stop when the partial solution is complete and record it. The key detail is pruning invalid choices early. Use a list or stack for state. Time is usually exponential.
Q. Given a table, write an SQL query to fetch specific information using a self-join.
asked 1xmediumSQLTechnical2021
Ans. Use a self-join by referencing the same table twice with different aliases and joining rows that have a relationship, such as employee.manager_id matching manager.id. Select the required columns from each alias. The key detail is to qualify every column with its alias so SQL knows which copy of the table you mean.
Q. Explain and analyze sorting algorithms, including their time and space complexities
asked 1xmediumSortingTechnical2020
Ans. Sorting algorithms arrange data in order, with trade-offs in time, space, stability and whether they sort in place. Bubble, selection and insertion sort are O(n²), though insertion is good on nearly sorted data. Merge sort is O(n log n) with O(n) space. Quick sort averages O(n log n), worst O(n²). Heap sort is O(n log n) and O(1) space.
Q. Implement the Floyd-Warshall algorithm to find all-pairs shortest paths in a graph.
asked 1xmediumGraphsOnline test2020
Ans. Use a V by V distance matrix, initialised with edge weights, 0 on the diagonal, and infinity where no edge exists. For each intermediate vertex k, update every pair i, j with dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]). It runs in O(V³) time and O(V²) space.
Q. How would you design and implement a distributed cache for a large-scale application?
asked 1xmediumDistributed systemsManagerial2023
Ans. I would build a sharded in-memory cache cluster using consistent hashing, with replicas for availability and clients routing requests to the right node. Each entry would have a TTL, size limits, and LRU or LFU eviction. The most important detail is defining cache consistency clearly, especially invalidation on writes and behaviour during node failures.
Q. Explain or apply the Floyd–Warshall algorithm to solve an all-pairs shortest path problem.
asked 1xmediumGraphsOnline test2020
Ans. Floyd Warshall finds shortest paths between every pair of vertices by repeatedly allowing each vertex to be an intermediate stop. Start with a distance matrix from edge weights, zero on the diagonal and infinity where no edge exists. For each intermediate k, update dist[i][j] if dist[i][k] plus dist[k][j] is smaller. It runs in O(n³) time.
Q. Given a number N, return the Kth nearest prime number based on absolute difference from N.
asked 1xmediumNumber theoryOnline test2021
Ans. Expand outwards from N by distance d, testing N - d and N + d for primality, and count primes found until the Kth is reached. Handle values below 2 as non-prime, and define a tie order, usually lower number first. Use trial division up to square root; time depends on gaps and primality checks.
Q. Write an algorithm to solve a real-life problem using standard computer science algorithms
asked 1xmediumAlgorithmsOnline test2020
Ans. Use Dijkstra’s algorithm to find the fastest route between two locations in a road network. Model junctions as nodes and roads as weighted edges, where weights are travel times. Use a min-priority queue to always expand the quickest known route next. With an adjacency list, the time complexity is O((V + E) log V).
Q. Given an array and a target sum, find the pair of elements whose sum is closest to the target.
asked 1xmediumArraysTechnical2023
Ans. Sort the array, then use two pointers from the start and end to track the pair whose sum has the smallest absolute difference from the target. If the sum is too small, move the left pointer right; if too large, move the right pointer left. This uses sorting and two pointers, taking O(n log n) time.
Q. How would you check whether a binary string has been transmitted correctly without any errors?
asked 1xmediumNetworkingTechnical2020
Ans. Compute an error-detecting value from the binary string before transmission, send it with the data, then recompute it at the receiver and compare. A parity bit is the simplest method, but it only detects an odd number of bit errors; a checksum or CRC is normally used for stronger detection.
Q. Write a program to extract data from two tables connected by a foreign key using PL instead of SQL
asked 1xmediumDBMSTechnical2018
Ans. Use a procedural block with cursors over both tables, store the parent table rows in a hash map keyed by primary key, then scan the child table and use its foreign key to find the matching parent row. This simulates a join procedurally. Time complexity is O(n + m), with O(n) extra memory.
Q. Form the largest even number possible using at most one swap operation on the digits of a given number.
asked 1xmediumGreedyOnline test2021
Ans. Return the lexicographically largest digit string among all valid choices: no swap if the number is already even, the best one-swap improvement that leaves an even last digit, and swaps of the last digit with each even digit. If no even digit exists, no solution exists. Use rightmost digit positions; time is linear, space constant.
Q. An array consists of 0s and 1s. Find the length of the longest subarray containing equal number of 0s and 1s.
asked 1xmediumArraysOnline test2019
Ans. Convert 0 to -1 and find the longest subarray with sum 0 using prefix sums. Keep a hash map from each prefix sum to its earliest index. When the same sum appears again, the elements between those indices are balanced. This runs in O(n) time and O(n) space.
Q. Find the area of the largest triangle that can be formed inside a rectangle and round it to the nearest integer
asked 1xmediumGeometryTechnical2018
Ans. The largest triangle area is half the rectangle’s area, so return round(width × height / 2). Use three corners of the rectangle to form the triangle, giving base equal to one side and height equal to the other. If coordinates are given, compute width and height by absolute differences. Time complexity is O(1).
Q. Given a 2D n x n matrix, print the sum of those diagonal elements whose count is greater than 3 in the entire matrix
asked 1xmediumArraysOnline test2020
Ans. Count frequencies of all matrix values, then traverse the main and secondary diagonals and add only values whose total frequency in the matrix is greater than 3. Use a hash map for counts. For an n by n matrix, counting takes O(n²) time, diagonal traversal takes O(n), and space is O(k) for distinct values.
Q. Explain object-oriented programming concepts such as inheritance, polymorphism, encapsulation and abstraction in C++/Java
asked 1xmediumOOPTechnical2018
Ans. Object-oriented programming models software as objects with state and behaviour. Encapsulation hides data behind methods and access modifiers. Abstraction exposes essential operations through classes or interfaces. Inheritance lets a class reuse and extend another class. Polymorphism lets the same method call behave differently through overriding, interfaces, or virtual methods.
Q. Explain Greedy Algorithms and Dynamic Programming. What is Quick Sort and Merge Sort? Compare their efficiency and use cases.
asked 1xmediumSortingTechnical2021
Ans. Greedy makes the best local choice at each step, while dynamic programming solves overlapping subproblems and stores results. Quick Sort partitions around a pivot, average O(n log n), worst O(n²), fast in-place. Merge Sort divides and merges, always O(n log n), needs extra space. Use Quick Sort for arrays, Merge Sort for stability or linked lists.
Q. Given an employee table with attributes (emp_id, emp_name, manager_id, etc.), find an employee named "Akash" who is not a manager
asked 1xmediumSQLTechnical2017
Ans. Select the employee row where emp_name is “Akash” and that employee’s emp_id does not appear as any other row’s manager_id. The safest approach is to use a NOT EXISTS check against the same employee table, because manager_id may contain NULL values and NOT IN can then give incorrect results.
Q. Given an integer array of size N, print all even numbers in non-decreasing order first, followed by all odd numbers in ascending order.
asked 1xmediumArraysOnline test2021
Ans. Separate the array into two lists, one for even numbers and one for odd numbers, sort both lists in ascending order, then print the even list followed by the odd list. The main detail is preserving the required ordering within each group. This takes O(N log N) time and O(N) extra space.
Q. What is the difference between Machine Learning and Deep Learning? Explain activation functions, vanishing gradient problem, and Leaky ReLU.
asked 1xmediumAi mlTechnical2021
Ans. Machine Learning is the broader field where models learn patterns from data, while Deep Learning uses multi-layer neural networks to learn features automatically. Activation functions add non-linearity so networks can model complex relationships. Vanishing gradients occur when gradients become too small in early layers. Leaky ReLU reduces this by allowing a small negative slope.
Q. Explain normalization, difference between triggers and cursors, RDBMS vs NoSQL databases, types of joins, primary key vs composite key, and indexing.
asked 1xmediumDBMSTechnical2021
Ans. Normalization organises relational data to reduce duplication and update anomalies. Triggers are automatic actions fired by database events, while cursors process query results row by row. RDBMS uses structured tables and SQL; NoSQL uses flexible models. Joins combine tables, commonly inner, left, right and full. A primary key uniquely identifies rows; a composite key uses multiple columns. Indexing speeds reads but slows writes.
Q. Given an array and an integer K, partition the array into K subarrays such that the maximum subarray sum is minimized. Return this minimum possible value.
asked 1xmediumBinary searchOnline test2020
Ans. Use binary search on the answer between the largest element and the total sum. For each candidate maximum sum, greedily scan the array and start a new subarray whenever adding the next element would exceed it. If more than K subarrays are needed, increase the limit; otherwise decrease it. Time complexity is O(n log sum).
Q. How would you find the second largest element in an unsorted array? How would you find the nth largest element? What is the time complexity in both cases?
asked 1xmediumArraysTechnical2016
Ans. Find the second largest by scanning once while tracking the largest and second largest values, updating them as each element is read. This takes O(n) time and O(1) space. For the kth largest element, use quickselect for average O(n) time, or a min heap of size k for O(n log k) time.
Q. Given two strings, sort the first string based on the order of character occurrences in the second string. Characters absent in the second string should appear at the end in their original relative order.
asked 1xmediumStringsOnline test2020
Ans. Count characters in the first string, then output characters following the order given by the second string, using their counts. While scanning the first string, keep characters not present in the second string in a separate list so their relative order is preserved. Use a hash map and set. Time complexity is O(n + m).
Q. Given a matrix, convert it into a square matrix by appending 1s where required, then compute the sum of diagonal elements such that a diagonal element is counted only if it appears an odd number of times outside the diagonal.
asked 1xmediumMatrixOnline test2021
Ans. Pad the matrix with 1s until rows and columns are both n, where n is the larger original dimension, then sum each main diagonal value only if its frequency in all non-diagonal cells is odd. Use a hash map to count non-diagonal values after padding, then scan the diagonal. Time is O(n²), space is O(n²) or O(k).
Q. Puzzle: There are socks of 20 different colors such that there are 1 pair of color c1, 2 pairs of c2, ..., up to 20 pairs of c20. What is the maximum number of socks you need to pick to guarantee at least one matching pair of the same color?
asked 1xmediumLogical reasoningTechnical2016
Ans. You need to pick 21 socks. In the worst case, you could first pick one sock from each of the 20 colours, giving no matching pair. The next sock must be one of those same 20 colours, so it must match a sock already picked. By the pigeonhole principle, the guarantee is 21.
Q. Given N villages arranged in a circular pattern with distances between consecutive villages and an energy drink at each village, determine the starting village index such that a traveler starting with zero energy can complete the full circle.
asked 1xmediumGreedyOnline test2020
Ans. Use a greedy scan: keep a running surplus of drink energy minus distance cost, and start at village 0. Whenever the surplus becomes negative, no village in that failed segment can be the answer, so set the next village as the start and reset surplus. If total surplus is non-negative, return that start index; otherwise none exists.
Q. Alice and Bob are given some number of chocolates. When Alice has more chocolates, she leaves chocolates in the box equal to the number Bob has, and vice versa. This continues until both have equal chocolates or one has zero. Find the number of times chocolates are left in the box.
asked 1xmediumMathOnline test2020
Ans. The answer is the number of subtraction steps needed to make the two counts equal or make one zero. This is the subtraction form of the Euclidean algorithm. Instead of subtracting one by one, add larger divided by smaller to the count, replace larger by larger mod smaller, and continue. Time complexity is logarithmic.
Q. Write an algorithm to find the maximum sum submatrix in a 2D array.
asked 1xhardArraysOnline test2021
Ans. Fix two column boundaries, compress the rows between them into a one dimensional array of row sums, then run Kadane’s algorithm on that array to find the best vertical span. Repeat for all column pairs and keep the maximum. Use an auxiliary sums array. Time complexity is O(cols squared times rows), or transpose to minimise it.
Q. Given an elevation map, compute how much water it can trap after raining.
asked 1xhardArraysTechnical2023
Ans. Use two pointers from both ends, tracking the maximum height seen on the left and right. Move the side with the smaller current height, because its trapped water is limited by that side’s maximum. Add max minus current height when positive. This uses constant extra space and runs in O(n) time.
Q. Reverse a singly linked list
asked 1xeasyLinked listsTechnical2022
Ans. Reverse it by walking through the list once and redirecting each node’s next pointer to the previous node. Keep three pointers: previous, current, and next, so you do not lose the remaining list. At the end, previous becomes the new head. Time is O(n), space is O(1).
Q. What is the difference between C and C++?
asked 1xeasyOOPTechnical2019
Ans. C is mainly a procedural systems programming language, while C++ extends C with object oriented and generic programming features. The key practical difference is that C++ provides classes, constructors, destructors, templates and a richer standard library, enabling abstractions such as RAII and containers while still supporting low level memory control.
Q. Have you ever been in charge of a team or a project?
asked 1xeasyLeadershipHR2021
Ans. Choose a real example where you had clear responsibility for people, delivery, or coordination. Emphasise the goal, your role, how you organised the work, handled issues, and measured success. Interviewers listen for ownership, communication, planning, judgement under pressure, and whether you helped others perform rather than simply doing everything yourself.
Q. How do you work as part of a team or as an individual?
asked 1xeasyTeamworkHR2021
Ans. Choose a situation that shows you can adapt between collaboration and ownership. Emphasise clear communication, reliability, sharing knowledge, and asking for help early when needed. For individual work, show self-management and accountability. Interviewers listen for maturity, flexibility, low ego, and evidence that you help the team succeed rather than just completing your own tasks.
Q. Given a number N, count how many numbers i in the range (1, N) satisfy (3 * i + 1) > N.
asked 1xeasyLogical reasoningOnline test2020
Ans. Solve the inequality first: 3i + 1 > N gives i > (N - 1) / 3. For integer i in the exclusive range (1, N), count values from floor((N - 1) / 3) + 1 up to N - 1, also ensuring i > 1. Thus use the valid lower bound and count inclusively.
Q. Given the 2nd and 3rd elements of an arithmetic progression (AP), find the nth element.
asked 1xeasyLogical reasoningOnline test2019
Ans. The nth element is found by first taking the common difference as third element minus second element. If the 2nd term is x and the 3rd term is y, then d = y - x. The nth term is x + (n - 2)d, so Tn = x + (n - 2)(y - x).
Q. English language and verbal ability questions
asked 1xunknownVerbalOnline test2018
Ans. Read the instruction first, then identify what skill is being tested, such as grammar, vocabulary, sentence order, inference or error spotting. Eliminate clearly wrong options using meaning, tone and grammar rules. For passages, read the question before the text and answer only from the given information, not outside knowledge.
Q. Explain a technical concept to someone who has never used a computer.
asked 1xunknownCommunicationManagerial2021
Ans. Pick a simple concept, such as the internet, passwords, or saving a file. Use a real situation where you adapted your language for a non-technical person. Emphasise analogies, patience, checking understanding, and avoiding jargon. Interviewers listen for clarity, empathy, structure, and evidence that you can make complex ideas useful.
Showing 60 of 119 questions. Ranked by how often the same question came back across interviews.