Add office photos
Employer?
Claim Account for FREE

Adobe

3.9
based on 1.1k Reviews
Video summary
Filter interviews by

60+ V&S Publishers Interview Questions and Answers

Updated 10 Sep 2024
Popular Designations

Q1. Delete the Middle Node from a Singly Linked List

Given a singly linked list of integers, the task is to remove the middle node from this list.

Input:

The first line of input includes an integer 'T' which denote...read more
Ans.

The task is to delete the middle node of a singly linked list of integers.

  • If the linked list is empty or has only one node, there is no middle node to delete.

  • To delete the middle node, we need to find the middle node and update the pointers of the previous and next nodes.

  • To find the middle node in one traversal, we can use two pointers - a slow pointer and a fast pointer.

  • The slow pointer moves one node at a time, while the fast pointer moves two nodes at a time.

  • When the fast ...read more

Add your answer

Q2. Morty's Array Challenge

Rick has provided Morty with an array 'Arr' of length 'N' and an integer 'K'. Morty needs to split the array into non-empty sub-arrays to achieve the minimum possible cost, subject to th...read more

Ans.

The challenge involves splitting an array into sub-arrays to minimize cost based on unique elements and repetitions.

  • Iterate through the array and keep track of unique elements and repetitions

  • Calculate cost for each sub-array based on the rules provided

  • Sum up the costs for all sub-arrays to get the total minimum cost

Add your answer

Q3. Sub Sort Problem Statement

You are given an integer array ARR. Determine the length of the shortest contiguous subarray which, when sorted in ascending order, results in the entire array being sorted in ascendi...read more

Ans.

The task is to find the length of the shortest contiguous subarray that needs to be sorted in order to sort the entire array.

  • Iterate through the array from left to right and find the first element that is out of order.

  • Iterate through the array from right to left and find the first element that is out of order.

  • Find the minimum and maximum elements within the subarray defined by the above two elements.

  • Expand the subarray to include any additional elements that are out of order ...read more

Add your answer

Q4. Problem: Search In Rotated Sorted Array

Given a sorted array that has been rotated clockwise by an unknown amount, you need to answer Q queries. Each query is represented by an integer Q[i], and you must determ...read more

Ans.

This is a problem where a sorted array is rotated and we need to search for given numbers in the array.

  • The array is rotated clockwise by an unknown amount.

  • We need to perform binary search to find the index of the given numbers.

  • If the number is found, return its index. Otherwise, return -1.

  • The time complexity of the solution should be O(logN).

Add your answer
Discover V&S Publishers interview dos and don'ts from real experiences

Q5. Quick Sort Problem Statement

You are provided with an array of integers. The task is to sort the array in ascending order using the quick sort algorithm.

Quick sort is a divide-and-conquer algorithm. It involve...read more

Ans.

The question asks to implement quick sort algorithm to sort an array of integers in ascending order.

  • Quick sort is a divide and conquer algorithm

  • Choose a pivot point and partition the array into two parts

  • Recursively sort the left and right parts of the array

  • Implement the quick sort algorithm to sort the given array

Add your answer

Q6. Swap Adjacent Bit Pairs Problem Statement

Given an integer N, your task is to compute the number that results from swapping each even position bit of N's binary representation with its adjacent odd bit to the r...read more

Ans.

The task is to swap each even bit of an integer with its adjacent bit on the right in its binary representation.

  • Convert the given integer to its binary representation

  • Iterate through the binary representation and swap each even bit with its adjacent bit on the right

  • Convert the modified binary representation back to an integer

  • Print the resulting integer

Add your answer
Are these interview questions helpful?

Q7. LCA in a Binary Search Tree

You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.

Your task is to determine the Lowest Common Anc...read more

Ans.

The task is to find the lowest common ancestor (LCA) of two given nodes in a binary search tree (BST).

  • The LCA is the lowest node that has both given nodes as descendants.

  • In a BST, the left subtree of a node contains only nodes with data less than the node's data, and the right subtree contains only nodes with data greater than the node's data.

  • Start from the root node and compare it with the given nodes. If both nodes are smaller than the current node, move to the left subtree...read more

Add your answer

Q8. Merge Two Sorted Linked Lists Problem Statement

You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.

Input:...read more

Ans.

The task is to merge two sorted linked lists into a single sorted linked list.

  • Create a new linked list to store the merged list

  • Compare the values of the nodes from both lists and add the smaller value to the new list

  • Move the pointer of the list with the smaller value to the next node

  • Repeat the comparison and addition until one of the lists is empty

  • Add the remaining nodes from the non-empty list to the new list

  • Return the head of the new list

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Spiral Matrix Problem Statement

You are given a N x M matrix of integers. Your task is to return the spiral path of the matrix elements.

Input

The first line contains an integer 'T' which denotes the number of ...read more
Ans.

The task is to return the spiral path of a given matrix.

  • Iterate through the matrix in a spiral pattern, starting from the outermost layer and moving towards the center.

  • Keep track of the current row, column, and the boundaries of the remaining unvisited matrix.

  • Print the elements in the spiral path as you traverse the matrix.

Add your answer

Q10. Stack with getMin Operation

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 without usi...read more

Ans.

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 the current minimum.

  • For getMin operation, simply return the...read more

Add your answer

Q11. Minimum Fountains Activation Problem

In this problem, you have a one-dimensional garden of length 'N'. Each position from 0 to 'N' has a fountain that can provide water to the garden up to a certain range. Thus...read more

Ans.

Find the minimum number of fountains to activate to water the entire garden.

  • Iterate through the array and keep track of the farthest point each fountain can cover.

  • Activate the fountain that covers the farthest point not covered by any previous fountain.

  • Continue this process until the entire garden is covered.

  • Return the count of activated fountains as the minimum number required.

Add your answer

Q12. Longest Common Prime Subsequence Problem Statement

Imagine Ninja is tackling a puzzle during his long summer vacation. He has two arrays of integers, each with lengths 'N' and 'M'. Ninja's task is to determine ...read more

Ans.

Find the length of the longest subsequence common to two arrays consisting only of prime numbers.

  • Iterate through both arrays and check if the numbers are prime.

  • Use dynamic programming to find the longest common subsequence of prime numbers.

  • Keep track of the length of the common prime subsequence.

  • Return the length of the longest common prime subsequence.

Add your answer

Q13. You have a lot of small integers in an array. You have to multiply all of them. You need not worry about overflow and range, you have enough support for that. What can you do to speed up the multiplication on y...

read more
Ans.

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 loop unrolling and vectorization.

  • Consider using specialized ...read more

Add your answer

Q14. Equilibrium Index Problem Statement

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 elements of...read more

Ans.

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.

Add your answer

Q15. Maximum Meetings Problem Statement

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 that t...read more

Ans.

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.

Add your answer

Q16. Split Array Problem Statement

You are given an integer array/list arr of size N. Your task is to split the array into the maximum number of subarrays such that the first and last occurrence of every distinct el...read more

Ans.

Split the array into maximum number of subarrays such that first and last occurrence of every distinct element lies within 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.

  • Count the number of subarrays where the first and last occurrence of each element are within the same subarray.

Add your answer

Q17. Split Array into 'K' Consecutive Subarrays Problem

Given an integer array arr of size N, determine if it is possible to split the array into K consecutive non-overlapping subarrays of length M such that each su...read more

Ans.

The problem involves splitting an array into 'K' consecutive subarrays of length 'M' with each subarray containing a single distinct element.

  • Iterate through the array and check if each subarray of length 'M' contains only one distinct element.

  • Keep track of the count of distinct elements in each subarray.

  • Return 1 if it is possible to split the array according to the condition, otherwise return 0.

Add your answer

Q18. Intersection of Two Arrays Problem Statement

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 includes ...read more

Ans.

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.

Add your answer

Q19. Max Product Subset Problem Statement

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 can b...read more

Ans.

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.

Add your answer

Q20. Split Array Into Maximum Subarrays Problem Statement

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 occurrence of...read more

Ans.

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.

Add your answer

Q21. Equalize Water in Buckets

You are provided with an array, ARR, of positive integers. Each integer represents the number of liters of water in a bucket. The goal is to make the water volume in each bucket equal ...read more

Ans.

Given an array of positive integers representing water in buckets, find the minimum amount of water to be removed to equalize all buckets.

  • Sort the array in non-decreasing order to easily identify the buckets with excess water.

  • Calculate the average water volume by dividing the total water volume by the number of buckets.

  • Iterate through the array and calculate the excess water in each bucket compared to the average.

  • Sum up the excess water in all buckets to get the minimum amoun...read more

Add your answer

Q22. Rat in a Maze Problem Statement

You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N matrix w...read more

Ans.

Find all possible paths for a rat in a maze from source to destination.

  • Use backtracking to explore all possible paths in the maze.

  • Keep track of visited cells to avoid revisiting them.

  • Explore all possible directions (up, down, left, right) from each cell.

  • Add the current direction to the path and recursively explore further.

  • When reaching the destination, add the path to the list of valid paths.

Add your answer

Q23. Minimize Cash Flow Problem

You are provided with a list of 'transactions' involving 'n' friends who owe each other money. Each entry in the list contains information about a receiver, sender, and the transactio...read more

Ans.

Minimize cash flow among friends by optimizing transactions.

  • Create a graph where nodes represent friends and edges represent transactions.

  • Calculate net amount each friend owes or is owed.

  • Use a recursive algorithm to settle debts by minimizing cash flow.

  • Update the graph after each transaction to reflect the new balances.

  • Repeat the process until all balances are settled.

Add your answer

Q24. Next Greater Element Problem Statement

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.

The Next...read more

Ans.

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

Add your answer
Q25. ...read more

Number In Arithmetic Progression Problem

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 sequence.

Ans.

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'

Add your answer

Q26. Maximum Sum Path in a Binary Tree Problem Statement

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 simpl...read more

Ans.

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.

Add your answer

Q27. Populating Next Right Pointers in Each Node

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.

Input:...read more

Ans.

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

Add your answer

Q28. Longest Zero Sum Subarray Problem

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 with mult...read more

Ans.

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.

Add your answer

Q29. Given a program: int i; int main() { int j; int *k = (int *) malloc (sizeof(int)); … } Where are each of these variables stored?

Ans.

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()

Add your answer
Q30. What is the Diamond Problem in C++ and how can it be resolved?
Ans.

The Diamond Problem is a conflict that occurs when a class inherits from two classes that have a common base class.

  • The Diamond Problem arises in multiple inheritance.

  • It occurs when a class inherits from two classes that have a common base class.

  • This leads to ambiguity in accessing the common base class members.

  • To fix the Diamond Problem, virtual inheritance is used.

  • Virtual inheritance ensures that only one instance of the common base class is inherited.

Add your answer
Q31. What are virtual destructors in C++?
Ans.

Virtual destructors in C++ are used to ensure that the correct destructor is called when deleting an object through a pointer to its base class.

  • Virtual destructors are declared in the base class and are used when deleting an object through a pointer to the base class.

  • They allow proper destruction of derived class objects.

  • Without virtual destructors, only the base class destructor would be called, leading to memory leaks and undefined behavior.

  • Virtual destructors are necessary...read more

Add your answer

Q32. Given a set of words one after another, give me a data structure so that you’ll know whether a word has appeared already or not

Ans.

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.

Add your answer
Q33. You have two wires of different lengths that are both capable of burning for exactly one hour when ignited at both ends. How can you measure a time interval of 45 minutes using these two wires?
Ans.

To measure 45 minutes using two wires of different lengths that burn for one hour when ignited at both ends.

  • Ignite one end of the first wire and both ends of the second wire simultaneously.

  • After 30 minutes, the second wire will burn out completely.

  • At this point, ignite the other end of the first wire.

  • When the first wire burns out completely, 45 minutes will have passed.

Add your answer
Q34. What are the different types of semaphores?
Ans.

Semaphores are synchronization primitives used in operating systems to control access to shared resources.

  • Binary semaphore: Can take only two values, 0 and 1. Used for mutual exclusion.

  • Counting semaphore: Can take any non-negative integer value. Used for resource allocation.

  • Mutex semaphore: A binary semaphore used for mutual exclusion.

  • Named semaphore: A semaphore that can be accessed by multiple processes.

  • Unnamed semaphore: A semaphore that can only be accessed by threads wit...read more

Add your answer

Q35. Given a polygon (could be regular, irregular, convex, concave), find out whether a particular point lies inside it or outside it

Ans.

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

Add your answer

Q36. Given an expression, remove unnecessary parenthesis. For example if (((a + b)) * c) is given make it (a + b) * c, as it evaluates in the same way without those parenthesis also

Ans.

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 precedence

  • Apply the rules recursively until no more unnece...read more

Add your answer
Q37. Explain how to overload the pre and post-increment operators in object-oriented programming.
Ans.

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; Counter& operator++() { value++; return *this; } Counter o...read more

Add your answer

Q38. Given an array of integers, find the maximum product which can be formed by three numbers

Ans.

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.

Add your answer

Q39. Given an array of integers, find the length of the longest consecutive sub array which forms an AP

Ans.

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

Add your answer

Q40. Which are the four storage classes in C

Ans.

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

View 1 answer

Q41. Memory allocation for static varibles(when,which segment etc)

Ans.

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.

Add your answer
Q42. Can you define process and threads in operating systems?
Ans.

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 are lightweight.

  • Example: A web browser running multiple tabs...read more

Add your answer

Q43. Given an integer(consider 4 bytes) find which byte is zero

Ans.

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.

Add your answer

Q44. Give an array of integers arr1, find a new array where array[i] = multiplication of all entries arr1 except arr1[i] without using division operator

Ans.

To find a new array where each element is the product of all elements in the original array except the element at that index without using division operator.

  • Iterate through the array and calculate the product of all elements to the left of the current index for each element.

  • Iterate through the array in reverse and calculate the product of all elements to the right of the current index for each element.

  • Multiply the results from the two steps above to get the final array.

Add your answer

Q45. Given a wholly sorted two dimensional array , find the index of given element or return -1 if not present

Ans.

Search for an element in a sorted 2D array and return its index if found

  • Start from the top right corner and compare the target element with the current element

  • If the target is smaller, move left; if larger, move down

  • Repeat until the element is found or all elements are checked

Add your answer

Q46. Given an array, find the Next Greatest Element to the right for each element

Ans.

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

Add your answer

Q47. Program to check whether your machine is little endian or big endian

Ans.

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

Add your answer

Q48. Find space and time complexity for a recursive function(he wrote it)

Ans.

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.

Add your answer

Q49. Gievn a binary tree and return all root to leaf node pathss row,col and value

Ans.

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.

Add your answer

Q50. Print something before execution of main()(use static objects)

Ans.

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

Add your answer

Q51. WHAT IS OOPS WHY OOPS WHY NOT OOPS

Ans.

OOPS stands for Object-Oriented Programming. It is a programming paradigm that uses objects and classes for code organization and reusability.

  • OOPS allows for better code organization and reusability through the use of classes and objects.

  • Encapsulation, inheritance, and polymorphism are key principles of OOPS.

  • Examples of OOPS languages include Java, C++, and Python.

Add your answer

Q52. WHAT IS DBMS WHY DBMS WHY NOT DBMS

Ans.

DBMS stands for Database Management System. It is used to manage and organize data efficiently. It provides data security, integrity, and easy access.

  • DBMS helps in organizing and managing data efficiently.

  • It ensures data security and integrity by providing access control and data encryption.

  • DBMS allows for easy retrieval and manipulation of data through query languages like SQL.

  • Examples of DBMS include MySQL, Oracle, and Microsoft SQL Server.

Add your answer

Q53. WHAT IS DSA WHAT IS WEB DEVELOPMENT

Ans.

DSA stands for Data Structures and Algorithms. Web development is the process of creating websites and web applications.

  • DSA involves organizing and storing data efficiently for quick access and manipulation

  • Web development includes front-end (client-side) and back-end (server-side) development

  • Examples of DSA include arrays, linked lists, and sorting algorithms

  • Examples of web development technologies include HTML, CSS, JavaScript, and frameworks like React and Node.js

Add your answer

Q54. Design a data structure for excel spreadsheet?

Ans.

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

Add your answer

Q55. Merge two sorted linked lists using recursion

Ans.

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

Add your answer

Q56. getMax() function for a stack in O(1)

Ans.

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)

Add your answer

Q57. WHAT IS SIEVE OF ERATOSTHENESE

Ans.

Sieve of Eratosthenes is an algorithm for finding all prime numbers up to a given limit.

  • Algorithm eliminates multiples of each prime number starting from 2

  • Remaining numbers are prime

  • Example: Finding prime numbers up to 30 - 2, 3, 5, 7, 11, 13, 17, 19, 23, 29

Add your answer

Q58. getMax() function for a queue in O(1)

Ans.

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

Add your answer

Q59. Explain insertion sort,quicksort

Ans.

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.

  • Both algorithms have an average time complexity of O(n log n)...read more

Add your answer

Q60. Operating on images in parallel

Ans.

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

Add your answer

Q61. Hardware engines support for parallelism

Ans.

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 languages and frameworks like OpenCL and CUDA can be used to lever...read more

Add your answer

Q62. Memory protection in OS?

Ans.

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 mechanisms include segmentation, paging, and access contro...read more

Add your answer

Q63. OS support for parallelism

Ans.

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.

Add your answer

Q64. Diamond heirarchy problem

Ans.

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

Add your answer

Q65. Tower of hanoi?

Ans.

Tower of Hanoi is a mathematical puzzle that involves moving a stack of disks from one peg to another.

  • The puzzle consists of three pegs and a number of disks of different sizes.

  • The objective is to move the entire stack to another peg, obeying the following simple rules:

  • - Only one disk can be moved at a time.

  • - Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack or on an empty peg.

  • - No disk may be placed on top of a smaller ...read more

Add your answer

Q66. unique path in a grid

Ans.

Find the number of unique paths in a grid from top left to bottom right

  • Use dynamic programming to store the number of paths to each cell

  • At each cell, the number of paths is the sum of paths from the cell above and the cell to the left

  • Example: For a 3x3 grid, there are 6 unique paths

Add your answer

Q67. maximum product in subarrray

Ans.

Find the maximum product of a subarray within an array of strings.

  • Iterate through the array and keep track of the maximum product so far

  • Consider both positive and negative numbers in the subarray

  • Handle edge cases like all negative numbers or empty array

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at V&S Publishers

based on 10 interviews
3 Interview rounds
Coding Test Round - 1
Coding Test Round - 2
HR Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.3
 • 36 Interview Questions
3.2
 • 35 Interview Questions
3.4
 • 24 Interview Questions
4.2
 • 23 Interview Questions
3.7
 • 17 Interview Questions
4.2
 • 11 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter