Filter interviews by
I applied via Campus Placement
Many questions are from reasoning
Must have to knowledge on any kind of language
Top trending discussions
To determine if a point is inside a polygon, use the ray casting algorithm.
Create a line from the point to a point outside the polygon
Count the number of times the line intersects with the polygon edges
If the count is odd, the point is inside the polygon; otherwise, it is outside
The four storage classes in C are auto, register, static, and extern.
Auto: default storage class for all local variables
Register: used to define local variables that should be stored in a register instead of RAM
Static: used to define local variables that retain their value between function calls
Extern: used to declare a global variable that is defined in another file
i is stored in global data segment, j is stored in stack, k is stored in heap.
i is a global variable and is stored in the global data segment
j is a local variable and is stored in the stack
k is a pointer variable and is stored in the stack, while the memory it points to is allocated on the heap using malloc()
Use a hash table to store the words and check for existence in constant time.
Create a hash table with the words as keys and a boolean value as the value.
For each new word, check if it exists in the hash table. If it does, it has appeared before. If not, add it to the hash table.
Alternatively, use a set data structure to store only the unique words and check for existence in the set.
I was interviewed before Jan 2021.
Round duration - 60 Minutes
Round difficulty - Medium
The interviewer asked me 2 questions related to DS/Algo in this round . Both the questions were of Easy-Medium difficulty and I was also required to code them in a production ready manner.
You are provided with a binary tree consisting of N
nodes where each node has an integer value. The task is to determine the maximum sum achievable by a...
Find the maximum sum achievable by a simple path between any two nodes in a binary tree.
Traverse the binary tree to find all possible paths and calculate their sums.
Keep track of the maximum sum encountered during traversal.
Consider paths that may include the same node twice.
Implement a recursive function to explore all possible paths.
Handle cases where nodes have negative values.
Given two arrays A
and B
with sizes N
and M
respectively, both sorted in non-decreasing order, determine their intersection.
The intersection of two arrays in...
The problem involves finding the intersection of two sorted arrays efficiently.
Use two pointers to iterate through both arrays simultaneously.
Compare elements at the pointers and move the pointers accordingly.
Handle cases where elements are equal, and update the intersection array.
Return the intersection array as the result.
Round duration - 50 Minutes
Round difficulty - Medium
This round had 2 questions of DS/Algo to solve under 50 minutes and one question related to Operating Systems.
You are provided with an array or list ARR
containing N
positive integers. Your task is to determine the Next Greater Element (NGE) for each element in the array.
T...
Find the Next Greater Element for each element in an array.
Iterate through the array from right to left
Use a stack to keep track of elements with no greater element to the right
Pop elements from the stack until finding a greater element or stack is empty
Given three integers X
, C
, and Y
, where X
is the first term of an arithmetic sequence with a common difference of C
, determine if Y
is part of this arithmetic sequ...
Check if a given number is part of an arithmetic sequence with a given first term and common difference.
Calculate the arithmetic sequence using the formula: nth term = X + (n-1) * C
Check if Y is equal to any term in the sequence to determine if it belongs to the sequence
Return 'True' if Y belongs to the sequence, otherwise return 'False'
Processes are instances of programs in execution, while threads are smaller units within a process that can execute independently.
A process is a program in execution, consisting of code, data, and resources.
Threads are smaller units within a process that can execute independently.
Processes have their own memory space, while threads share the same memory space within a process.
Processes are heavyweight, while threads ar...
Round duration - 50 Minutes
Round difficulty - Medium
This round had 2 questions of DSA of Easy-Medium difficulty and at the end I was asked a Puzzle to check my general problem solving ability.
Given an array/list arr
of size n
, determine the maximum product possible by taking any subset of the array/list arr
. Return the result modulo 10^9+7
since the product ...
Find the maximum product of a subset of an array modulo 10^9+7.
Iterate through the array and keep track of the maximum positive product and minimum negative product encountered so far.
Handle cases where the array contains zeros separately.
Return the maximum product modulo 10^9+7.
Given a complete binary tree with 'N' nodes, your task is to determine the 'next' node immediately to the right in level order for each node in the given tree.
...Implement a function to update 'next' pointers in a complete binary tree.
Iterate level by level using a queue
Connect nodes at each level using 'next' pointers
Handle null nodes appropriately
Ensure the tree is a complete binary tree
Round duration - 50 Minutes
Round difficulty - Medium
This round consisted of 2 questions from DSA where I was first asked to explain my approach to the interviewer with proper complexity analysis and then code the problems. The interviewer was quite friendly and also provided me some hints when I was stuck.
Create a stack data structure that supports not only the usual push and pop operations but also getMin(), which retrieves the minimum element, all in O(1) time complexity witho...
Implement a stack with push, pop, top, isEmpty, and getMin operations in O(1) time complexity without using extra space.
Use two stacks - one to store the actual elements and another to store the minimum element at each level.
When pushing an element, check if it is smaller than the current minimum and update the minimum stack accordingly.
When popping an element, also pop from the minimum stack if the popped element is t...
You are given an integer array arr
of size N
. Your task is to split the array into the maximum number of subarrays such that the first and last occurre...
Given an array, split it into maximum subarrays with first and last occurrence of each element in a single subarray.
Iterate through the array and keep track of the first and last occurrence of each element.
Use a hashmap to store the indices of each element.
Split the array whenever the last occurrence of an element is found.
Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
Return all root to leaf node paths in a binary tree with row, col and value.
Traverse the binary tree recursively and keep track of the current path.
When a leaf node is reached, add the path to the result array.
Include row, col and value of each node in the path.
Use an array of strings to store the paths.
To get max value from a stack in O(1), maintain a separate stack to keep track of maximum values.
Create a separate stack to keep track of maximum values
Push the maximum value onto the stack whenever a new maximum is encountered
Pop the maximum value stack whenever the top element of the main stack is popped
Return the top element of the maximum value stack to get the maximum value in O(1)
To get max element from a queue in O(1) time complexity
Maintain a separate variable to keep track of the maximum element in the queue
Update the maximum element variable whenever a new element is added or removed from the queue
Return the maximum element variable when getMax() function is called
Find the Next Greatest Element to the right for each element in an array of strings.
Iterate through the array from right to left
Use a stack to keep track of elements
Pop elements from stack until a greater element is found
If no greater element is found, assign -1
Return the result array
To remove unnecessary parenthesis from an expression, we need to apply a set of rules to identify and eliminate them.
Identify and remove parenthesis around single variables or constants
Identify and remove parenthesis around expressions with only one operator
Identify and remove parenthesis around expressions with operators of equal precedence
Identify and remove parenthesis around expressions with operators of different ...
Find the maximum product of three integers in an array.
Sort the array in descending order.
Check the product of the first three numbers and the product of the first and last two numbers.
Return the maximum of the two products.
Find length of longest consecutive sub array forming an AP from given array of integers.
Sort the array in ascending order
Iterate through the array and find the longest consecutive sub array forming an AP
Use a variable to keep track of the length of the current consecutive sub array forming an AP
Use another variable to keep track of the length of the longest consecutive sub array forming an AP seen so far
I was interviewed before Sep 2020.
Round duration - 90 mintues
Round difficulty - Easy
Timing it is around 1 pm, Environment is very friendly.
Given an array Arr
consisting of N integers, your task is to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elem...
Find the equilibrium index of an array where sum of elements on left equals sum of elements on right.
Iterate through the array and calculate the total sum of elements.
For each index, calculate the sum of elements on the left and right side and check for equilibrium.
Return the left-most equilibrium index found, or -1 if none exist.
Given the schedule of N meetings with their start time Start[i]
and end time End[i]
, you need to determine which meetings can be organized in a single meeting room such ...
Given N meetings with start and end times, find the maximum number of meetings that can be organized in a single room without overlap.
Sort the meetings based on end times.
Iterate through the sorted meetings and select the next meeting whose start time is greater than or equal to the end time of the previous meeting.
Return the selected meetings in the order they are organized.
Round duration - 90 mintues
Round difficulty - Hard
Timing it is around 1 pm and Environment is good .
Overloading pre and post-increment operators in OOP involves defining special member functions for the class.
Define member functions for pre-increment (++obj) and post-increment (obj++) operators in the class.
For pre-increment, return a reference to the modified object after incrementing the value.
For post-increment, return a copy of the original object before incrementing the value.
Example: class Counter { int value; ...
Given an array of integers consisting of both positive and negative numbers, find the length of the longest subarray whose sum is zero. This problem will be presented wit...
Find the length of the longest subarray with zero sum in an array of integers.
Iterate through the array and keep track of the running sum using a hashmap.
If the running sum is seen before, it means there is a subarray with zero sum.
Calculate the length of the subarray with zero sum and update the maximum length found so far.
Tip 1 : Practice Atleast 500 Questions
Tip 2 : Do atleast 1 good projects
Tip 3 : You should be able to explain your project
Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.
Operating on images in parallel involves dividing the image into smaller parts and processing them simultaneously.
Divide the image into smaller parts using techniques like tiling or splitting
Use parallel processing techniques like multi-threading or GPU acceleration
Combine the processed parts to form the final image
Examples: image segmentation, object detection, image enhancement
Hardware engines support parallelism through multiple cores and threads.
Hardware engines can have multiple cores and threads to execute tasks simultaneously.
Parallelism can improve performance and efficiency in hardware-based tasks.
Examples include GPUs, FPGAs, and ASICs that have parallel processing capabilities.
Hardware parallelism can also be achieved through distributed computing and clustering.
Programming language...
Modern OSes support parallelism through multi-core processors and threading.
Modern OSes like Windows, macOS, and Linux support parallelism through multi-core processors and threading.
Parallelism can be achieved through processes or threads.
Parallelism can improve performance and efficiency of software.
Examples of parallel programming frameworks include OpenMP and MPI.
Memory protection is a feature of an operating system that prevents unauthorized access to memory locations.
Memory protection is achieved through the use of memory management units (MMUs) and virtual memory.
MMUs map virtual addresses to physical addresses and enforce access permissions.
Virtual memory allows the OS to allocate memory to processes in a way that isolates them from each other.
Examples of memory protection ...
To speed up multiplication of small integers in an array, we can use bitwise operations and parallel processing.
Use bitwise operations like shifting and ANDing to perform multiplication faster.
Divide the array into smaller chunks and perform multiplication in parallel using multi-threading or SIMD instructions.
Use lookup tables for frequently used values to avoid repeated calculations.
Use compiler optimizations like lo...
Design a data structure for excel spreadsheet
Use a 2D array to store cell values
Implement formulas using a stack
Include formatting options for cells
Insertion sort and quicksort are sorting algorithms used to sort arrays of data.
Insertion sort: iterates through the array and inserts each element into its proper position.
Quicksort: selects a pivot element and partitions the array into two sub-arrays, one with elements less than the pivot and one with elements greater than the pivot.
Insertion sort is best for small arrays, while quicksort is best for large arrays.
Bot...
Merge two sorted linked lists using recursion
Create a recursive function that compares the first nodes of both lists
Set the smaller node as the head of the merged list and call the function again with the next node of the smaller list
Base case: if one list is empty, return the other list
Return the merged list
Given an integer, determine which byte is zero.
Convert the integer to a byte array using bitwise operations.
Iterate through the byte array and check for a zero value.
Return the index of the zero byte.
Consider endianness when converting to byte array.
To check endianness, create a 4-byte integer with a known value and check the byte order.
Create a 4-byte integer with a known value
Check the value of the first byte to determine endianness
If the first byte is the least significant, the machine is little endian
If the first byte is the most significant, the machine is big endian
Static objects can be used to print something before main() execution.
Static objects are initialized before main() execution
They can be used to print something before main()
Example: static int x = printf("Hello World!");
Output: Hello World! will be printed before main() execution
Static variables are allocated memory in the data segment of the program's memory space.
Static variables have a fixed memory location throughout the program's execution.
They are initialized to zero by default.
If initialized explicitly, they are stored in the data segment.
Static variables can be accessed by any function in the program.
Finding space and time complexity of a recursive function.
Space complexity is the amount of memory used by the function.
Time complexity is the amount of time taken by the function to execute.
Recursive functions have higher space complexity due to the call stack.
Time complexity can be calculated using Big O notation.
Examples of recursive functions include factorial and Fibonacci sequence.
Diamond hierarchy problem is a problem in object-oriented programming where a class inherits from multiple classes in a diamond-shaped hierarchy.
Occurs when a class inherits from two classes that share a common base class
Can lead to ambiguity in method calls and data members
Solved using virtual inheritance or by using interfaces
Find the minimum and maximum values in an array in a single traversal.
Initialize min and max variables with the first element of the array
Iterate through the array and update min and max if a smaller or larger value is found
Return the min and max values
The maximum number of squares on a chessboard is 64.
The chessboard has 64 squares in total.
The number of squares on a chessboard can be calculated using the formula n^2, where n is the number of rows or columns.
In this case, n = 8 (8 rows and 8 columns), so the maximum number of squares is 8^2 = 64.
C++ is a programming language. Deep copy creates a new object and copies all values, while shallow copy creates a reference to the original object.
C++ is a general-purpose programming language
Deep copy creates a new object with its own copy of the data
Shallow copy creates a reference to the original object
Deep copy is safer but can be slower and consume more memory
Shallow copy is faster but can lead to unexpected behav
Pre initialization refers to the process of initializing variables or objects before they are used in a program.
Pre initialization helps avoid errors or unexpected behavior caused by using uninitialized variables.
It is a good practice to pre initialize variables with default values.
Pre initialization can be done using constructors, default values, or initialization blocks.
Example: int count = 0; initializes the variabl
Reverse a linked list with and without using Recursion
Iterative approach: Use three pointers to reverse the links between nodes
Recursive approach: Recursively reverse the rest of the list and then fix the links
Polymorphism refers to the ability of an object to take on many forms. The diamond problem occurs in multiple inheritance.
Polymorphism can be achieved through method overloading and method overriding.
Method overloading allows multiple methods with the same name but different parameters.
Method overriding occurs when a subclass provides a specific implementation of a method already defined in its superclass.
The diamond p...
The program should differentiate between integers and characters when using the assignment operator (=).
Check the data type of the variable before assigning a value.
Use conditional statements to perform different actions based on the data type.
For integers, assign the value directly. For characters, convert the character to its ASCII value and assign it.
Sort an array by moving all zeroes to the end.
Iterate through the array and move all non-zero elements to the front.
Count the number of zeroes encountered and append them at the end of the array.
Use two pointers to swap elements and maintain the order.
The number of VTables created in a class hierarchy depends on the number of virtual functions and the number of derived classes.
VTables are used in object-oriented programming languages to implement dynamic dispatch.
Each class with at least one virtual function has its own VTable.
Derived classes inherit the VTable of their base class and add their own entries for any additional virtual functions.
The total number of VTa...
List is preferred when frequent insertion and deletion is required. Vector is preferred when random access is required.
List is implemented as a doubly-linked list, allowing for efficient insertion and deletion at any position.
Vector is implemented as a dynamic array, allowing for efficient random access.
Use List when the number of elements is expected to change frequently and the order of elements matters less.
Use Vect...
The given string needs to be reversed and the words need to be rearranged.
Split the string into an array of words
Reverse the array
Join the array elements with a space in between
Design a parking lot with Logic Flow Diagram, E-R diagram, DB tables with relations, and commands for transactions.
Identify the types of vehicles that will use the parking lot
Determine the number of parking spaces needed for each vehicle type
Create a flow diagram to show the process of entering and exiting the parking lot
Design an E-R diagram to show the relationships between entities such as vehicles, parking spaces, ...
To find min and max of an array in one traversal, initialize min and max to first element and compare with rest.
Initialize min and max to first element of array
Traverse the array and compare each element with min and max
Update min and max accordingly
Return min and max
Given a chessboard, find the maximum number of squares present.
Start with the smallest square and count all possible squares
Use the formula n*(n+1)*(2n+1)/6 to find the total number of squares in an n x n chessboard
Add up the squares of all sizes from 1 to n to get the maximum number of squares
For example, an 8 x 8 chessboard has 204 squares
C++ is a high-level programming language used for developing system software, application software, device drivers, and video games.
C++ was developed by Bjarne Stroustrup in 1983.
It is an extension of the C programming language.
C++ supports object-oriented programming, generic programming, and low-level memory manipulation.
It is used in developing operating systems, browsers, databases, and more.
Examples of popular sof...
Deep copy creates a new object with a new memory address, while shallow copy creates a new reference to the same memory address.
Deep copy duplicates the object and all its nested objects, while shallow copy only duplicates the top-level object.
Deep copy is slower and more memory-intensive than shallow copy.
Shallow copy can lead to unexpected behavior if the original object is modified.
In Python, deep copy can be achiev...
Preinitialization is the process of initializing data or objects before they are actually needed.
Preinitialization can improve performance by reducing the time needed to initialize data or objects when they are actually needed.
It can also help to avoid delays or interruptions during runtime.
Examples of preinitialization include preloading data into memory, initializing objects in advance, and caching frequently used da
Polymorphism can be achieved through method overloading, method overriding, and interfaces. Multiple inheritance can be solved using interfaces.
Method overloading allows multiple methods with the same name but different parameters
Method overriding allows a subclass to provide its own implementation of a method already defined in its superclass
Interfaces provide a way to achieve multiple inheritance by allowing a class ...
WAP to generate a matrix from a given tree.
Create a 2D array to store the matrix
Traverse the tree and fill the matrix accordingly
Use BFS or DFS to traverse the tree
The matrix will be symmetric along the diagonal
Primary key is a column or set of columns that uniquely identifies each row in a table. Unique key is a constraint that ensures uniqueness of values in a column or set of columns.
Primary key is used to enforce data integrity and ensure that each row in a table can be uniquely identified.
Unique key is used to ensure that no two rows in a table have the same values in a column or set of columns.
Primary key can be a singl...
Yes, a unique key can be a primary key.
A primary key is a unique identifier for a record in a table.
A unique key is a constraint that ensures the values in a column are unique.
A unique key can be used as a primary key if it meets the requirements.
A primary key cannot have NULL values, while a unique key can have one NULL value.
Foreign key is a column in a table that refers to the primary key of another table.
It establishes a relationship between two tables.
It ensures referential integrity.
It can be null, but only if it is defined as nullable.
It helps in joining tables.
Example: Customer table has a foreign key to the Order table's primary key.
Example: Order table's foreign key can be null if the order has not been placed by any customer yet.
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.
Normalization involves breaking down a database into smaller, more manageable tables.
It helps to eliminate data redundancy and inconsistencies.
Normalization ensures that each table has a primary key and that data is stored in a logical and consistent manner.
It improves data integrity and reduces the likelihood ...
Normalized form is better for data consistency and scalability.
Normalized form reduces data redundancy and ensures data consistency.
Normalized form allows for easier scalability and maintenance.
Single table/2 tables may be appropriate for small, simple datasets.
Normalized form may require more complex queries to retrieve data.
Normalized form may require more storage space due to additional tables.
Example: Normalized fo...
Create a database for Indian Premier League (IPL)
Identify entities like teams, players, matches, venues, etc.
Create tables for each entity with relevant attributes
Establish relationships between tables using foreign keys
Add constraints like unique, not null, default values, etc.
Populate tables with data from reliable sources
Query to find player with maximum runs in a match on given date and venue
Use MAX() function to find maximum runs
Join tables for player name, match details and runs scored
Filter by given date and venue
Order by runs scored and limit to 1 result
based on 1 interview
Interview experience
based on 3 reviews
Rating in categories
Software Developer
13
salaries
| ₹0 L/yr - ₹0 L/yr |
UI Developer
9
salaries
| ₹0 L/yr - ₹0 L/yr |
Web Developer
7
salaries
| ₹0 L/yr - ₹0 L/yr |
Front end Developer
7
salaries
| ₹0 L/yr - ₹0 L/yr |
Ai Ml Engineer
5
salaries
| ₹0 L/yr - ₹0 L/yr |
Oracle
Amdocs
Carelon Global Solutions
Automatic Data Processing (ADP)