Filter interviews by
I applied via Company Website
Arrays are fixed in size while ArrayLists can dynamically grow or shrink.
Arrays are of fixed size while ArrayLists can be resized dynamically.
Arrays can hold primitive data types while ArrayLists can only hold objects.
Arrays are faster than ArrayLists for accessing elements.
ArrayLists have built-in methods for adding, removing, and sorting elements.
Example: int[] arr = new int[5]; ArrayList
Queue can be implemented using a singly linked list where insertion happens at the tail and deletion at the head.
Create a Node class with data and next pointer
Create a Queue class with head and tail pointers
Enqueue operation: create a new node and add it to the tail of the list
Dequeue operation: remove the node at the head of the list and update the head pointer
Peek operation: return the data at the head of the list wi
To fill a BST with a sorted array, we can use a recursive approach.
Find the middle element of the array and make it the root of the BST
Recursively construct the left subtree using the left half of the array
Recursively construct the right subtree using the right half of the array
Fibonacci number generation using recursion
Define a function that takes an integer as input
If the input is 0 or 1, return the input
Else, return the sum of the function called with input-1 and input-2
Call the function with the desired input
The fastest sorting algorithm is QuickSort.
QuickSort has an average time complexity of O(n log n).
It is a divide and conquer algorithm that recursively partitions the array.
It is widely used in practice and has many variations such as randomized QuickSort.
Other fast sorting algorithms include MergeSort and HeapSort.
Clone a linked list with a random pointer.
Create a new node for each node in the original list
Store the mapping of original node to new node in a hash table
Set the random pointer of each new node based on the mapping
Traverse the original list and the new list simultaneously to set the next pointers
Printing Fibonacci numbers using recursion only
Define a recursive function that takes two arguments, n and a list to store the Fibonacci sequence
Base case: if n is 0 or 1, return the list
Recursive case: append the sum of the last two elements in the list to the list and call the function with n-1
Call the function with n and an empty list to start the sequence
Print the list of Fibonacci numbers
Reflection in Java allows inspection and modification of runtime behavior of a program.
Reflection is achieved through classes in the java.lang.reflect package.
It allows access to class information, constructors, methods, and fields at runtime.
Reflection can be used to create new objects, invoke methods, and access or modify fields.
Example: Class c = Class.forName("java.lang.String");
Example: Method m = c.getDeclared
Given an array of integers and a target sum, find a pair of integers that add up to the target sum.
Create a hash table to store the difference between the target sum and each element in the array
Iterate through the array and check if the current element is present in the hash table
If it is, return the current element and its corresponding hash table value as the pair that adds up to the target sum
If no such pair is fou
Binary search in a rotated array can be done by finding the pivot point and then applying binary search on the two subarrays.
Find the pivot point by comparing mid element with the first and last elements of the array
Apply binary search on the two subarrays formed by the pivot point
Repeat until the element is found or the subarray is empty
Time complexity is O(log n)
Example: [4,5,6,7,0,1,2], target=0. Pivot point is 3. B
Negative elements in array won't affect binary search. Time complexity remains O(log n).
Binary search works by dividing the array into two halves and comparing the middle element with the target element.
If the middle element is greater than the target, search in the left half, else search in the right half.
Negative elements won't affect this process as long as the array is sorted.
Time complexity remains O(log n) as the
Array rotation is the process of shifting the elements of an array to the left or right.
To rotate an array to the left, move the first element to the end of the array and shift the remaining elements to the left.
To rotate an array to the right, move the last element to the beginning of the array and shift the remaining elements to the right.
The number of rotations can be specified by the user.
Example: If the array is [...
Polymorphism is the ability of an object to take on many forms. It allows objects of different classes to be treated as if they were of the same class.
Polymorphism is achieved through method overriding and method overloading.
Method overriding is when a subclass provides its own implementation of a method that is already provided by its parent class.
Method overloading is when a class has two or more methods with the sam...
Overloading is having multiple methods with the same name but different parameters. Overriding is having a method in the subclass with the same name and parameters as in the superclass.
Overloading is compile-time polymorphism while overriding is runtime polymorphism.
Overloading is used to provide different ways of calling the same method while overriding is used to provide a specific implementation of a method in the s...
A list of technical questions related to data structures and algorithms in Java.
Arrays are fixed in size while ArrayLists can dynamically grow and shrink.
Queue can be implemented using a linked list by adding elements to the end and removing from the front.
To fill a BST with a sorted array, we can recursively divide the array in half and add the middle element as the root.
Random pointer linked-list clone can be done by...
Polymorphism is the ability of an object to take on many forms. Overloading is having multiple methods with the same name but different parameters. Overriding is having a method in a subclass with the same name and parameters as a method in the superclass.
Polymorphism allows objects to be treated as if they are of different types. For example, a parent class reference can be used to refer to a child class object.
Overlo...
Top trending discussions
I was interviewed in Aug 2017.
N queen problem is to place N queens on an NxN chessboard without any two queens threatening each other.
The problem can be solved using backtracking algorithm
Start with placing a queen in the first row and move to the next row
If no safe position is found, backtrack to the previous row and try a different position
Repeat until all queens are placed or no safe position is found
Code can be written in any programming langua...
Check if there exists any sub array with given sum in the array with O(1K) space complexity.
Use two pointers to traverse the array and maintain a current sum.
If the current sum is greater than the given sum, move the left pointer.
If the current sum is less than the given sum, move the right pointer.
If the current sum is equal to the given sum, return true.
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.
References and pointers are both used to access memory locations, but references cannot be null and cannot be reassigned.
Pointers can be null and can be reassigned to point to different memory locations.
References are automatically dereferenced, while pointers need to be explicitly dereferenced.
Pointers can perform arithmetic operations, while references cannot.
Example: int x = 5; int *ptr = &x; int &ref = x;
Example: i
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...
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...
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...
B trees and B+ trees are data structures used for efficient storage and retrieval of data in databases.
B trees are balanced trees with a variable number of child nodes per parent node. They are commonly used in databases to store large amounts of data.
B+ trees are a variant of B trees where all data is stored in the leaf nodes, and the internal nodes only contain keys. They are commonly used in databases for indexing.
B...
AVL trees are self-balancing binary search trees. They maintain a balance factor to ensure height balance.
AVL trees are named after their inventors, Adelson-Velsky and Landis.
They are height-balanced, meaning the difference in height between left and right subtrees is at most 1.
Insertion and deletion operations may cause imbalance, which is corrected by rotations.
AVL trees have a worst-case time complexity of O(log n) ...
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
I applied via Campus Placement and was interviewed in May 2021. There was 1 interview round.
I applied via Referral and was interviewed in Apr 2021. There were 4 interview rounds.
2 variable variation of LIS
The problem involves finding the longest increasing subsequence in two arrays
Dynamic programming can be used to solve the problem
The time complexity of the solution is O(n^2)
Example: Given two arrays [1, 3, 5, 4] and [2, 4, 3, 5], the longest increasing subsequence is [3, 5]
Example: Given two arrays [10, 22, 9, 33, 21, 50, 41, 60] and [5, 24, 39, 60, 15, 28, 27, 40], the longest increasing su
Search for an element in a rotated sorted array.
Use binary search to find the pivot point where the array is rotated.
Compare the target element with the first element of the array to determine which half to search.
Perform binary search on the selected half to find the target element.
Time complexity: O(log n), Space complexity: O(1).
Find the first non-repeating character in a continuous character stream.
Use a hash table to keep track of character frequency.
Iterate through the stream and check if the current character has a frequency of 1.
If yes, return the character as the first non-repeating character.
If no non-repeating character is found, return null or a default value.
Prepare from hackerrank array and trees problems
I applied via Company Website and was interviewed in Jan 2022. There were 2 interview rounds.
Asked 2 questions
1. Find the strings with maximum pattern match in given array of strings
2. Find the shortest distance between two target elements in given array
It was a part of placement drive, 1st OA than interview. The OA round was super easy I was able to code in minutes.
I applied via Company Website and was interviewed before Nov 2021. There were 3 interview rounds.
General Leet Code Question and it was easy
General coding question which was from difficult
Some of the top questions asked at the RaRa Delivery interview -
based on 4 reviews
Rating in categories
Software Development Engineer
4
salaries
| ₹0 L/yr - ₹0 L/yr |
Product Manager
4
salaries
| ₹0 L/yr - ₹0 L/yr |
Senior Software Engineer
4
salaries
| ₹0 L/yr - ₹0 L/yr |
HR Associate
3
salaries
| ₹0 L/yr - ₹0 L/yr |
TCS
Accenture
Wipro
Cognizant