Filter interviews by
Be the first one to contribute and help others!
I appeared for an interview in Aug 2017.
NP hardness refers to the difficulty of solving a problem in non-deterministic polynomial time.
NP-hard problems are some of the most difficult problems in computer science.
They cannot be solved in polynomial time by any known algorithm.
Examples include the traveling salesman problem and the knapsack problem.
A reference variable is a variable that holds the memory address of an object, while an actual reference is the object itself.
A reference variable is declared with a specific type and can only refer to objects of that type.
An actual reference is the object itself, which can be accessed and manipulated using the reference variable.
Changing the value of a reference variable does not affect the original object, but changi...
The 0-1 Knapsack problem involves maximizing value within a weight limit using items that can either be included or excluded.
Dynamic Programming approach is commonly used to solve this problem.
Each item has a weight and a value; you cannot take fractional items.
Example: If you have items with weights [1, 2, 3] and values [10, 15, 40], and a capacity of 6, the maximum value is 55.
The solution involves creating a table t...
When we type an URL, the browser sends a request to the server hosting the website and retrieves the corresponding webpage.
The browser parses the URL to extract the protocol, domain, and path.
It resolves the domain name to an IP address using DNS.
The browser establishes a TCP connection with the server.
It sends an HTTP request to the server.
The server processes the request and sends back an HTTP response.
The browser re...
Implementation of LRU cache using a doubly linked list and a hash map.
LRU (Least Recently Used) cache is a data structure that stores a fixed number of items and evicts the least recently used item when the cache is full.
To implement LRU cache, we can use a doubly linked list to maintain the order of items based on their usage frequency.
We can also use a hash map to store the key-value pairs for quick access and retrie...
Explaining page replacement algorithms like FIFO and LRU using a given page access sequence.
FIFO (First-In-First-Out): Replaces the oldest page in memory.
Example: Access sequence [1, 2, 3, 1, 2, 4] with 3 frames results in [1, 2, 4].
LRU (Least Recently Used): Replaces the page that hasn't been used for the longest time.
Example: Access sequence [1, 2, 3, 1, 2, 4] with 3 frames results in [2, 3, 4].
Optimal: Replaces the ...
Indexing in DBMS is a technique to improve query performance by creating a data structure that allows faster data retrieval.
Indexing is used to speed up data retrieval operations in a database.
It involves creating a separate data structure that maps the values of a specific column to their corresponding records.
This data structure is called an index.
Indexes are typically created on columns that are frequently used in s...
Given a list of process IDs and their corresponding parent process IDs, print the IDs of all processes that are children of a specific process ID, and recursively kill all their children.
Iterate through the list of process IDs and parent process IDs
Check if the current process ID is the one to be killed
If yes, recursively find and print all its children
If a child has further children, recursively kill them as well
Prepare from hackerrank array and trees problems
I applied via Campus Placement and was interviewed in May 2021. There was 1 interview round.
It was a part of placement drive, 1st OA than interview. The OA round was super easy I was able to code in minutes.
Per question time good amoubnt of questions
Java is a versatile, object-oriented programming language used for building applications across various platforms.
Java is platform-independent due to the Java Virtual Machine (JVM). For example, code written in Java can run on any device with a JVM.
It supports Object-Oriented Programming (OOP) principles like inheritance, encapsulation, and polymorphism. For instance, a 'Car' class can inherit from a 'Vehicle' class.
Ja...
I applied via LinkedIn and was interviewed in Jul 2022. There were 2 interview rounds.
I applied via Campus Placement and was interviewed in Jul 2022. There was 1 interview round.
Given a node in a family tree, print all nodes on the same level.
Traverse the tree level by level using BFS
Keep track of the level of each node while traversing
Print all nodes with the same level as the given node
Example: If the given node is 'John', print all his siblings and cousins
I applied via Campus Placement and was interviewed before Aug 2021. There were 2 interview rounds.
2 coding questions were asked, 1 invloves sorting and manipulation and the other one was trees question.
Connect n ropes with minimum cost using priority queue
Create a priority queue and insert all the ropes into it
Pop the two smallest ropes from the queue and connect them
Insert the new rope into the queue and repeat until only one rope remains
The cost of connecting two ropes is the sum of their lengths
Time complexity: O(nlogn)
Example: Ropes of lengths 4, 3, 2, and 6 can be connected with a cost of 29
The height of the tree can be found by counting the number of edges from the root to the farthest leaf node.
Count the number of edges from the root to the farthest leaf node
This will give the height of the tree
Example: If the farthest leaf node is 4 edges away from the root, the height of the tree is 4
I applied via Campus Placement and was interviewed before Jul 2023. There were 3 interview rounds.
Basic leetcode and hard one question
Matrix multiplication involves multiplying the elements of one matrix with another matrix.
Create two matrices with compatible dimensions
Multiply corresponding elements of each row in the first matrix with each column in the second matrix
Sum the products to get the resulting matrix
1. Question on Graph LC-Hard 2. Question on BFS LC-Medium
Calculate the minimum number of platforms required at a railway station for given arrival and departure times.
Sort arrival and departure times.
Use two pointers to track platforms needed at any time.
Increment platform count on arrival and decrement on departure.
Example: For arrivals [10:00, 10:15] and departures [10:30, 10:45], 2 platforms are needed.
Find missing number in array without extra space
Iterate through the array and XOR all the elements with their indices and the actual numbers
The missing number will be the XOR result
Example: ['1', '2', '4', '5'] -> XOR(0, 1) ^ XOR(1, 2) ^ XOR(2, 4) ^ XOR(3, 5) = 3
Implementing Heap data structure in C++
Use an array to represent the binary tree structure of the heap
Implement functions for inserting elements, deleting elements, and heapifying the array
Ensure that the heap property is maintained (parent node is always greater than or equal to its children)
LRU Cache is a data structure that stores a fixed number of items and removes the least recently used item when the cache is full.
Use a combination of a doubly linked list and a hashmap to efficiently implement LRU Cache.
Keep track of the least recently used item at the tail of the linked list.
When an item is accessed, move it to the head of the linked list to mark it as the most recently used item.
When adding a new it...
TCS
Accenture
Wipro
Cognizant