Accolite Interview Questions  

See also
Top 45 Ruby interview questions for 2021
Please click Like if you loved this article?

Array Questions Accolite

Question 1. Count pair with Given Sum In problem “count pair with given sum” we have given an integer array[] and another number say ‘sum’, you have to determine whether any of the two elements in a given array has a sum equal to “sum”. Example   Input: arr []={1,3,4,6,7} and sum = 9. Output: “ Elements found ...

Read more

Question 2. Group Multiple Occurrence of Array Elements Ordered by first Occurrence You are given a question in which you have given an unsorted array with multiple occurrences of numbers. The task is to group all the multiple occurrences of array elements ordered by first occurrence. Meanwhile, the order should be the same as the number comes. Example   Input: [ 2, 3,4,3,1,3,2,4] ...

Read more

Question 3. Maximum difference between frequency of two elements such that element having greater frequency is also greater Suppose, you have an integer array. The problem statement asks to find out the maximum difference between the frequency of any two distinct elements of a given array, but the element with the greater frequency should also be greater in value than the other integer. Example   Input: arr[] = {2,4,4,4,3,2} ...

Read more

Question 4. All Unique Triplets that Sum up to a Given Value We have given an array of integers and a given number called ‘sum’. The problem statement asks to find out the triplet that adds up to the given number ‘sum’. Example   Input: arr[] = {3,5,7,5,6,1} sum=16 Output: Please click Like if you loved this article? (3, 7, 6), (5, 5, ...

Read more

Question 5. Segregate 0s and 1s in an Array Problem Statement   Suppose you have an integer array. The problem “Segregate 0s and 1s in an array” asks to segregate the array in two parts, in 0s and in 1s. The 0’s should be on the left side of the array and 1’s on the right side of the array. ...

Read more

Question 6. Find Largest d in Array such that a + b + c = d Problem Statement   Suppose you have an array of integers. Input values are all distinct elements. The problem “Find largest d in array such that a + b + c = d” asks to find out the largest element ‘d’ in the set such that a + b + c = ...

Read more

Question 7. Maximum Consecutive Numbers Present in an Array Problem Statement   Suppose you have an array of integers of size N. The problem “Maximum consecutive numbers present in an array” asks to find out the maximum count of consecutive numbers that could be scattered in an array. Example   arr[] = {2, 24, 30, 26, 99, 25} 3 Explanation: The ...

Read more

Question 8. Find whether an array is subset of another array The problem “Find whether an array is subset of another array” states that you are given two arrays arra1[] and array2[]. The arrays given are in an unsorted manner. Your task is to find whether the array2[] is a subset of array1[]. Example   arr1= [1,4,5,7,8,2] arr2= [1,7,2,4] arr2 [] is ...

Read more

Question 9. Maximum sum of pairs with specific difference The problem “Maximum sum of pairs with specific difference” states that you are given an array of integers and an integer K. Then we are asked to find out the maximum sum of independent pairs. We can pair two integers if they have an absolute difference of less than K. ...

Read more

Question 10. Print all triplets in sorted array that form AP The problem “Print all triplets in sorted array that form AP” states that we have given a sorted integer array. The task is to find out all the possible triplets that can form an Arithmetic Progression. Example   arr[] = {1,3,5,7,8,12,15,16,20,30} (1, 3, 5), (3, 5, 7), (1, 8, 15), (8, ...

Read more

Question 11. Count number of triplets with product equal to given number The problem “Count number of triplets with product equal to given number” states that we are given an integer array and a number m. The problem statement asks to find out the total number of triplets of with product equals to m. Example   arr[] = {1,5,2,6,10,3} m=30 3 Explanation Triplets ...

Read more

Question 12. Maximum difference between first and last indexes of an element in array Suppose, you have an array of integers. The problem “Maximum difference between first and last indexes of an element in array” asks to find out the difference between the first and last index of each number present in an array such that the difference is being maximum of all. Example   ...

Read more

Question 13. Find elements which are present in first array and not in second The problem “Find elements which are present in first array and not in second” states that you are given two arrays. Arrays consist of all the integers. You have to find out the numbers which will not be present in the second array but present in the first array. Example   ...

Read more

Question 14. Maximum product of an increasing subsequence Problem Statement   The problem “Maximum product of an increasing subsequence” states that you are given an array of integers. Now you need to find out the maximum product you can achieve such that you multiply the elements of an increasing subsequence. The thing to note is that, we are not ...

Read more

Question 15. Form minimum number from given sequence The problem “Form minimum number from given sequence” states that you are given some pattern of I’s and D’s only. The meaning of I stands for increasing and for decreasing we are provided with D. The problem statement asks to print the minimum number which satisfies the given pattern. We have ...

Read more

Question 16. Non-overlapping sum of two sets Problem Statement   The problem “Non-overlapping sum of two sets” states that you are given two arrays as input values as arrA[] and arrB[] of the same size n. Also, both of the arrays have distinct elements individually and some common elements. Your task is to find out the total sum ...

Read more

Question 17. Products of ranges in an array Problem Statement   The problem “Products of ranges in an array” states that you are given an integer array consisting of numbers range from 1 to n and q number of queries. Each query contains the range. The problem statement asks to find out the product within the given range under ...

Read more

Question 18. First negative integer in every window of size k Problem Statement   The problem “First negative integer in every window of size k” states that you are given an array containing positive and negative integers, for every window of size k print the first negative integer in that window. If there is no negative integer in any window then output ...

Read more

Question 19. Segregate even and odd numbers Problem Statement   Suppose you have an integer array. The problem “Segregate even and odd numbers” asks to rearrange the array so that the odd and even numbers can be separated in two segments of the array. The even numbers be shifted into the left side of the array and odd ...

Read more

Question 20. Product of array except self Problem Statement   “Product of array except self” problem, states that you are given an array a [ ]. Print another array p [ ] of the same size such that value at i’th index of array p is equal to the product of all the elements of the original array ...

Read more

Question 21. First missing positive Problem Statement   “First missing positive” problem states that you are given an array a[ ] (sorted or unsorted) of size n. Find the first positive number that is missing in this array. Example   a[ ] = {1, 3, -1, 8}  2 Explanation: If we sort the array we get {-1, ...

Read more

Question 22. Program for Bridge and Torch problem Problem Statement   The “Bridge and Torch” problem states that you are given an array of time a person needs to cross the bridge. Since it is time, it comprises positive integers. Along with the time we are given a bridge, which a person needs to cross. The bridge allows only ...

Read more

Question 23. Count quadruples from four sorted arrays whose sum is equal to a given value x Problem Statement   Problem “Count quadruples from four sorted arrays whose sum is equal to a given value x” state that you are given four integer arrays and a value called x. The problem statement asks to find out how many quadruplets can be formed of which sum of elements of ...

Read more

Question 24. Numbers with prime frequencies greater than or equal to k Problem Statement   Problem “Numbers with prime frequencies greater than or equal to k” states that you are given an array of integers size n and an integer value k. All the numbers inside it are prime numbers. The problem statement asks to find out the numbers which appear in the ...

Read more

Question 25. Maximum Subarray Sum Excluding Certain Elements Problem Statement   We are given an array, and we need to find maximum subarray sum excluding certain elements. That is, we need to find the max sum of subarray such that the subarray we are considering does not contain the elements which are told to be excluded. Example of maximum ...

Read more

Question 26. Find minimum number of merge operations to make an array palindrome Problem Statement   You are given an array of integers. The problem statement asks to find minimum number of merge operations to make an array palindrome, i.e. find out the minimum number of merging operations to be done on the array to make it a palindrome. Merging operation simply means that ...

Read more

Question 27. Maximum sum rectangle in a 2D matrix Problem Statement   Find the maximum sum rectangle in a 2D matrix i.e. to find a sub-matrix with maximum sum. A sub-matrix is nothing but a 2D array inside of the given 2D array. So, you have a matrix of signed integers, you need to calculate the sum of sub-matrices and ...

Read more

Question 28. Largest Sum Contiguous Subarray Problem Statement   You are given an array of integers. The problem statement asks to find out the largest sum contiguous subarray. This means nothing but to find a subarray (continuous elements) which has the largest sum among all other subarrays in the given array. Example   arr[] = {1, -3, 4, ...

Read more

Question 29. Count Distinct Elements in Every Window of Size K Subsets are something which we have been dealing with for some time now. In the last episode, we covered the number of subsets we could make with distinct even numbers. This time we count distinct elements in every window of size K. Section-1   About the problem. Given an unsorted array ...

Read more

Question 30. Count Pairs Whose Products Exist in Array In count pairs whose products exist in array problem we have given an array, count all the distinct pairs whose product value is present in the array. Example   Input A[]={2, 5, 6, 3, 15} Output Number of distinct pairs whose product exists in the array is: 2 Please click Like ...

Read more

Question 31. Count Pairs With Given Sum Given an integer array of size n, and an integer  ‘K’, you need to count the number of pairs(need not to be unique) present in the array whose sum is equal to ‘K’. Example   Input: Arr={1,  5,  7, 1} K=6 Output: Please click Like if you loved this article? 2 Brute force solution ...

Read more

Question 32. Check if an Array is Stack Sortable In check if an array is stack sortable problem we have given an array a[ ] of size n containing elements from 1 to n in random order. Sort the array in ascending order using a temporary stack following only these two operations – Remove the element at the starting ...

Read more

Question 33. Find Top K (or Most Frequent) Numbers in a Stream In find top k (or most frequent) numbers in a stream problem, we have given an integer array consisting of some numbers. The problem statement says that you have to take an element from the array, and you can only have at most k numbers at the top. We need ...

Read more

Question 34. Number of NGEs to the Right In the Number of NGEs to the right problem we have given an array a[ ] of size n and q number of queries representing the index of the array. For each query, i print the total number of next greater elements to it’s right. Example   Input a[ ] = ...

Read more

Question 35. Find the Subarray of given length with Least Average Problem Statement   In the “Find the Subarray of given length with Least Average” problem we have given an array and an input integer X. Write a program to find the subarray of length X with least/minimum average. Prints the starting and ending indexes of the subarray which has the least ...

Read more

Question 36. Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized Problem Statement   In the “Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized” problem we have given a binary array and a number x which denotes the no. of zeros to be flipped. Write a program to find the zeros that need to be flipped so ...

Read more

Question 37. Find the two Numbers with Odd Occurrences in an Unsorted Array Problem Statement   In the “Find the two Numbers with Odd Occurrences in an Unsorted Array” problem we have given an unsorted array. In this array other than two numbers all other numbers occur even number of times. Find the two numbers that occur an odd number of times. Note: The ...

Read more

Question 38. Implement Two Stacks in an Array Problem Statement   In the “Implement Two Stacks in an Array” problem we have to implement two stacks in an array such that, if the user wants to push an element in either of two stacks then there should not be an error till the array gets full. Example   Push 5 ...

Read more

Question 39. Tug of War Problem Statement   In tug of war problem, we have given an array of integers, divide the array into two subsets of size n/2 size each so that the difference of the sum of two subsets is as minimum as possible. If n is even each subset size is n/2. If ...

Read more

Question 40. Partition Problem Problem Statement   In the Partition problem, we have given a set that contains n elements. Find whether the given set can be divided into two sets whose sum of elements in the subsets is equal. Example   Input arr[] = {4, 5, 11, 9, 8, 3} Output Yes Please click Like ...

Read more

Question 41. Find the Lost Element From a Duplicated Array Problem Statement   Given two arrays A and B, one array is a duplicate of the other except one element. The one element is missing from either A or B. we need to find the lost element from a duplicated array. Example   5 1 6 4 8 9 6 4 8 ...

Read more

Question 42. Find Triplet in Array With a Given Sum Problem Statement   Given an array of integers, find the combination of three elements in the array whose sum is equal to a given value X. Here we will print the first combination that we get. If there is no such combination then print -1. Example   Input N=5, X=15 arr[] = ...

Read more

Question 43. Smallest Positive Number Missing in an Unsorted Array Problem Statement   In the given unsorted array find the smallest positive number missing in an unsorted array. A positive integer doesn’t include 0. We can modify the original array if needed. The array may contain positive and negative numbers. Example   a. Input array : [3, 4, -1, 0, -2, 2, 1, ...

Read more

Question 44. Maximum Sum of Non Consecutive Elements Problem Statement   In the “Maximum Sum of Non Consecutive Elements” given array, you need to find the maximum sum of non-consecutive elements. You can not add immediate neighbor numbers. For example [1,3,5,6,7,8,] here 1, 3 are adjacent so we can’t add them, and 6, 8 are not adjacent so we ...

Read more

Question 45. Multiplication of Previous and Next Problem Statement   Multiplication of Previous and Next: In the given array replace every element with the product of next and previous elements to it. And for the first element(a[0]) we need to replace it with the product of next and itself, for  the last element(a[n-1]) we need to replace it ...

Read more

Question 46. A Product Array Puzzle Problem Statement   In a product array puzzle problem we need to construct an array where the ith element will be the product of all the elements in the given array except element at the ith position. Example   Input  5 10 3 5 6 2 Output Please click Like if you ...

Read more

String Questions Accolite

Question 47. Form minimum number from given sequence The problem “Form minimum number from given sequence” states that you are given some pattern of I’s and D’s only. The meaning of I stands for increasing and for decreasing we are provided with D. The problem statement asks to print the minimum number which satisfies the given pattern. We have ...

Read more

Question 48. Rearrange a binary string as alternate x and y occurrences Problem Statement   Suppose you are given a binary string, and two numbers x and y. The string consists of 0s and 1s only. The problem “Rearrange a binary string as alternate x and y occurrences” asks to rearrange the string such that the 0 comes x times ⇒ 1 comes ...

Read more

Question 49. Reverse words in a string Problem Statement   “Reverse words in a string” states that you are given a string s of size n. Print the string in reverse order such that the last word becomes the first, second last becomes the second, and so on. Hereby string we refer to a sentence containing words instead ...

Read more

Question 50. KMP Algorithm KMP(Knuth-Morris-Pratt) algorithm is used for pattern searching in a given string. We are given a string S and a pattern p, our goal is to determine whether or not the given pattern is present in the string. Example   Input: S = “aaaab” p = “aab” Output: true Naive Approach   The ...

Read more

Question 51. Reverse a String using Stack We have given a string s of length n which contains lower case letters, upper case letters, integers, and some special symbol. Reverse the given string using stack. Let’s see some examples for better understanding. Example   Input  s = “TutorialCup” Output  Please click Like if you loved this article? puClairotuT ...

Read more

Question 52. Rabin Karp Algorithm Rabin Karp Algorithm used to find the pattern string in the given text string. There are so many types of algorithms or methods used to find the pattern string. In this algorithm, we use Hashing for finding the pattern matching. If we got the same hash code for the substring ...

Read more

Question 53. Sort a String According to Another String Problem Statement   Given two input strings, a pattern and a string. We need to sort the string according to the order defined by the pattern. Pattern string has no duplicates and it has all characters of the string. Input Format   The first line containing a string s which we need ...

Read more

Question 54. Longest Common Prefix using Divide and Conquer Problem Statement   In the “Longest Common Prefix using Divide and Conquer ” problem, we have given an integer n and n strings. Write a program that will print the longest common prefix. If there is no common prefix then print “-1”. Input Format   The first line contains an integer n. ...

Read more

Question 55. Print Shortest Path to Print a String on Screen Problem Statement   In the “Print Shortest Path to Print a String on Screen” problem we have given a screen containing alphabets from A-Z and input string, by using remote we can go from one character to another character, remote contains only left, right, top, and bottom keys. write a function ...

Read more

Question 56. Online Algorithm for Checking Palindrome in a Stream Problem Statement   In the “Online Algorithm for Checking Palindrome in a Stream” problem, we have given a stream of characters(charcaters are received one by one). Write a program that will print ‘yes’ every time if the received characters till now form a palindrome. Input Format   The first and only one ...

Read more

Question 57. Check if Two given Strings are Isomorphic to each other Problem Statement   In the “Check if Two given Strings are Isomorphic to each other” problem we have given two strings s1 and s2. Write a program that says whether the given strings are isomorphic or not. Note: Two strings are said to be isomorphic if there is a one to ...

Read more

Tree Questions Accolite

Question 58. Given a binary tree, how do you remove all the half nodes? The problem “Given a binary tree, how do you remove all the half nodes?” states that you are given a binary tree. Now you need to remove the half nodes. A half node is defined as a node in the tree that has only a single child. Either it is ...

Read more

Question 59. Boundary Traversal of binary tree Problem Statement   The problem “Boundary Traversal of binary tree” states that you are given a binary tree. Now you need to print the boundary view of a binary tree. Here boundary traversal means that all the nodes are shown as the boundary of the tree. The nodes are seen from ...

Read more

Question 60. Bottom View of a Binary Tree Problem Statement   The problem “Bottom View of a Binary Tree” states that you are given a binary tree and now you need to find the bottom view for the given tree. When we see a tree from the downward direction. The nodes which are visible to us is the bottom ...

Read more

Question 61. Print Right View of a Binary Tree Problem Statement   The problem “Print Right View of a Binary Tree” states that you are given a binary tree. Now you need to find the right view of this tree. Here, right view of the binary tree means to print the sequence as the tree looks when looked from the ...

Read more

Question 62. Binary Search Tree Delete Operation Problem Statement   The problem “Binary Search Tree Delete Operation” asks us to implement the delete operation for binary search tree. Delete function refers to the functionality to delete a node with a given key/data. Example   Input Node to be deleted = 5 Output Please click Like if you loved this ...

Read more

Question 63. Iterative Method to find Height of Binary Tree Problem Statement   The problem “Iterative Method to find Height of Binary Tree” states that you are given a binary tree, find the height of the tree using the iterative method. Examples   Input 3 Input 4 Algorithm for Iterative Method to find Height of Binary Tree   The height of a tree ...

Read more

Question 64. Clone a Binary Tree with Random Pointers Problem Statement   You are given a complete binary tree with some random pointers. Random pointers are referred to nodes which every node points to other than its left and right child. So, this also changes the standard structure of a node in a simple binary tree. Now the node of ...

Read more

Question 65. Find k-th smallest element in BST (Order Statistics in BST) Problem Statement   “Find k-th smallest element in BST (Order Statistics in BST)” problem states that you are given a binary search tree and you need to find the k-th smallest number in the BST. This means if we do an in-order traversal of the binary search tree and store the ...

Read more

Question 66. A program to check if a binary tree is BST or not Problem Statement   “A program to check if a binary tree is BST or not” states that you are given a binary tree and you need to check if the binary tree satisfies the properties of the binary search tree. So, the binary tree has the following properties:  The left subtree ...

Read more

Question 67. Print Ancestors of a Given Binary Tree Node Without Recursion Given a binary tree and a specific node or key. Print ancestors of a given binary tree node without recursion. Example   Input : key = 7 Please click Like if you loved this article? Output : 3 1 Input : key = 4 Output : 2 1 Algorithm for Ancestors of a ...

Read more

Question 68. Print a Binary Tree in Vertical Order In this problem, we have given a pointer denoting the root of the binary tree and your task is to print the binary tree in the vertical order. Example   Input 1 / \ 2 3 / \ / \ 4 5 6 7 \ \ 8 9 Output 4 2 ...

Read more

Graph Questions Accolite

Question 69. Topological Sorting Given a directed acyclic graph, topologically sort the graph nodes. Topological Sorting Example   Topological sorting of above graph is -> {1,2,3,0,5,4} Theory Topological Sorting is done for a Directed Acyclic Graph (DAG). A DAG has no cycles in it. ie, there is no such path starting from any node of ...

Read more

Question 70. Dijkstra Algorithm Dijkstra is the shortest path algorithm. Dijkstra algorithm is used to find the shortest distance of all nodes from the given start node. It logically creates the shortest path tree from a single source node, by keep adding the nodes greedily such that at every point each node in the ...

Read more

Stack Questions Accolite

Question 71. Form minimum number from given sequence The problem “Form minimum number from given sequence” states that you are given some pattern of I’s and D’s only. The meaning of I stands for increasing and for decreasing we are provided with D. The problem statement asks to print the minimum number which satisfies the given pattern. We have ...

Read more

Question 72. Print Ancestors of a Given Binary Tree Node Without Recursion Given a binary tree and a specific node or key. Print ancestors of a given binary tree node without recursion. Example   Input : key = 7 Please click Like if you loved this article? Output : 3 1 Input : key = 4 Output : 2 1 Algorithm for Ancestors of a ...

Read more

Question 73. Queue using Stacks In queue using a stack problem, we have to implement the following functions of a queue using the standard functions of stack data structure, Enqueue: Add an element to the end of the queue Dequeue: Remove an element from the start of the queue Example   Input: Enqueue(5) Enqueue(11) Enqueue(39) Dequeue()  ...

Read more

Question 74. Reversing a Queue In Reversing a Queue problem we have given a queue, write an algorithm to reverse the queue. Examples   Input queue = 10 -> 8 -> 4 -> 23 Output queue = 23->4->8->10 Input queue = 11 -> 98 -> 31 -> 42 -> 73 -> 6 Output queue = 6 ...

Read more

Question 75. Check if an Array is Stack Sortable In check if an array is stack sortable problem we have given an array a[ ] of size n containing elements from 1 to n in random order. Sort the array in ascending order using a temporary stack following only these two operations – Remove the element at the starting ...

Read more

Question 76. Reverse a String using Stack We have given a string s of length n which contains lower case letters, upper case letters, integers, and some special symbol. Reverse the given string using stack. Let’s see some examples for better understanding. Example   Input  s = “TutorialCup” Output  Please click Like if you loved this article? puClairotuT ...

Read more

Question 77. Number of NGEs to the Right In the Number of NGEs to the right problem we have given an array a[ ] of size n and q number of queries representing the index of the array. For each query, i print the total number of next greater elements to it’s right. Example   Input a[ ] = ...

Read more

Question 78. Implement Two Stacks in an Array Problem Statement   In the “Implement Two Stacks in an Array” problem we have to implement two stacks in an array such that, if the user wants to push an element in either of two stacks then there should not be an error till the array gets full. Example   Push 5 ...

Read more

Queue Questions Accolite

Question 79. Iterative Method to find Height of Binary Tree Problem Statement   The problem “Iterative Method to find Height of Binary Tree” states that you are given a binary tree, find the height of the tree using the iterative method. Examples   Input 3 Input 4 Algorithm for Iterative Method to find Height of Binary Tree   The height of a tree ...

Read more

Question 80. First negative integer in every window of size k Problem Statement   The problem “First negative integer in every window of size k” states that you are given an array containing positive and negative integers, for every window of size k print the first negative integer in that window. If there is no negative integer in any window then output ...

Read more

Question 81. Queue using Stacks In queue using a stack problem, we have to implement the following functions of a queue using the standard functions of stack data structure, Enqueue: Add an element to the end of the queue Dequeue: Remove an element from the start of the queue Example   Input: Enqueue(5) Enqueue(11) Enqueue(39) Dequeue()  ...

Read more

Question 82. Reversing a Queue In Reversing a Queue problem we have given a queue, write an algorithm to reverse the queue. Examples   Input queue = 10 -> 8 -> 4 -> 23 Output queue = 23->4->8->10 Input queue = 11 -> 98 -> 31 -> 42 -> 73 -> 6 Output queue = 6 ...

Read more

Matrix Questions Accolite

Question 83. Maximum sum rectangle in a 2D matrix Problem Statement   Find the maximum sum rectangle in a 2D matrix i.e. to find a sub-matrix with maximum sum. A sub-matrix is nothing but a 2D array inside of the given 2D array. So, you have a matrix of signed integers, you need to calculate the sum of sub-matrices and ...

Read more

Question 84. Print Shortest Path to Print a String on Screen Problem Statement   In the “Print Shortest Path to Print a String on Screen” problem we have given a screen containing alphabets from A-Z and input string, by using remote we can go from one character to another character, remote contains only left, right, top, and bottom keys. write a function ...

Read more

Other Questions Accolite

Question 85. Union and Intersection of two Linked Lists Given two linked lists, create another two linked lists to get union and intersection of the elements of existing lists. Example   Input: List1: 5 → 9 → 10 → 12 → 14 List2: 3 → 5 → 9 → 14 → 21 Output: Please click Like if you loved this ...

Read more

Question 86. Total Numbers With no Repeated Digits in a Range You are given a range of numbers (start, end). The given task says to find out the total numbers of numbers with no repeated digits in a range. Example   Input: 10 50 Output: 37 Please click Like if you loved this article? Explanation: 10 has no repeated digit. 11 has ...

Read more

Question 87. Write a function to get the intersection point of two Linked Lists Problem Statement   The problem “Write a function to get the intersection point of two Linked Lists” states that you are given two linked lists. But they are not independent linked lists. They are connected at some point. Now you need to find this point of intersection of these two lists. ...

Read more

Question 88. Linked List Cycle Problem Statement   “Linked List Cycle” problem states that you are given a linked list. Find if it contains any loop or not?  Linked list with cycle Example   1->2->3 No Loop Explanation: The linked list does not contain any loop because if it did then there would’ve been two no des ...

Read more

Question 89. Find Number of Employees Under every Employee HashMaps are one of the most useful data structures. Find the number of employees under every employee is a problem that reminds me of the famous movie’s inception. Akin to dream in a dream. Here, we have an employee working under an employee and so on. Problem Statement   So, what ...

Read more

Question 90. Top K Frequent Words In top K frequent words problem, we have given a list of words and an integer k. Print k most frequently used strings in the list.    Example   Input : list = {“code”, “sky”, “pen”, “sky”, “sky”, “blue”, “code”} k = 2 Output :  Please click Like if you loved ...

Read more

Question 91. N queen problem N queen problem using the concept of Backtracking. Here we place queen such that no queen under attack condition. The attack condition of the queens is if two queens are on the same column, row, and diagonal then they are under attack. Let’s see this by the below figure. Here ...

Read more

Question 92. Reverse a linked list Problem Statement   The problem “reverse a linked list” states that we are given the head of the linked list. We have to reverse the linked list by changing the links between them and return the head of the reversed linked list. Example   10->20->30->40->NULL NULL<-10<-20<-30<-40 Explanation We have reversed the linked ...

Read more

Question 93. Find Nth Node Problem Statement   In the “Find Nth Node” problem we have given a linked list to find the nth node. The program should print the data value in the nth node. N is the input integer index. Example   3 1 2 3 4 5 6 3 Approach   Given a linked list ...

Read more