**Please click Like if you loved this article?**

Categories of Questions

## Array Questions Coursera

**Question 1. 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. ...

**Question 2. Largest subarray with equal number of 0s and 1s** You are given an array of integers. The integers are only 0 and 1 in the input array. The problem statement asks to find out the largest sub-array that can have equal count of 0s and 1s. Example arr[]={0,1,0,1,0,1,1,1} 0 to 5 (total 6 elements) Explanation From the array position ...

**Question 3. Binary array after M range toggle operations** You are given a binary array, which consists of 0 initially and Q number of queries. The problem statement asks to toggle the values (converting 0s into 1s and 1s into 0s). After the Q queries performed, print the resultant array. Example arr[] = {0, 0, 0, 0, 0} Toggle(2,4) ...

**Question 4. Queries for counts of array elements with values in given range** Problem Statement The problem “Queries for counts of array elements with values in given range” states that you have an integer array and two number x and y. The problem statement asks to find out the count of numbers present in array that lies between the given x and y. ...

**Question 5. Distinct adjacent elements in an array** Problem Statement Suppose we have an integer array. The problem “Distinct adjacent elements in an array” asks to determine if it is possible to get the array in which all the adjacent numbers are distinct or not by swapping up two adjacent or neighbour elements in an array if it ...

**Question 6. Count subarrays with equal number of 1’s and 0’s** Problem Statement The problem “Count subarrays with equal number of 1’s and 0’s” states that you are given an array consisting of 0’s and 1’s only. The problem statement asks to find out the count of sub-arrays consisting equal no of 0’s ad 1’s. Example arr[] = {0, 0, 1, ...

**Question 7. Find the minimum distance between two numbers** Problem Statement You have given an array and two numbers called x and y. The problem “Find the minimum distance between two numbers” asks to find out the minimum possible distance between them. The array given can have common elements. You can assume that both x and y are different. ...

**Question 8. Size of The Subarray With Maximum Sum** Problem Statement You are given an array of integers. The given array can contain both positive and negative numbers. Find out the size of the subarray with maximum sum. Example arr[] = {1,4,-2,-5,2-1,4,3} 4 Explanation: 2 -1 + 4 + 3 = 8 is maximum sum of length 4 arr[] ...

**Question 9. Count minimum steps to get the given desired array** Problem Statement Suppose you have an array containing only integer 0 as all of its elements. Consider, you are given an array of length n having all 0s in which we have to convert the 0s to the given required array. We can name the required array as the desiredArr ...

**Question 10. Smallest Subarray With all Occurrences of a Most Frequent Element** In the smallest subarray with all occurrences of a most frequent element problem, we have given an array. Take a number “m” in an array with the maximum frequency. The problem statement says that you have to find out the smallest subarray which also has all the occurrence of number ...

## String Questions Coursera

**Question 11. Text Justification** Problem Statement The problem “Text Justification” states that you are given a list s[ ] of type string of size n and an integer size. Justify the text such that each line of text consists of size number of characters. You can use space(‘ ‘) as a character to complete ...

**Question 12. Regular Expression Matching** In the Regular Expression Matching problem we have given two strings one (let’s assume it x) consists of only lower case alphabets and second (let’s assume it y) consists of lower case alphabets with two special characters i.e, “.” and “*”. The task is to find whether the second string ...

**Question 13. Even Substring Count** Problem Statement In the “Even Substring Count” problem we have given an input string which is formed by digits. Write a program or code to find the count of substrings which when converting into integer form even. Input Format The first and only one line containing a string “s”. Output ...

**Question 14. Minimum Characters to be Removed to Make a Binary String Alternate** Problem Statement Given a binary string, write a program that will find the minimum number of characters that can be removed from this string so that it becomes alternate. A binary string is said to be alternate if there are no consecutive 0’s or 1’s Input Format The first line ...

## Tree Questions Coursera

**Question 15. Binary Tree to Binary Search Tree Conversion using STL set** Problem Statement We are given a binary tree and we need to convert it into a binary search tree. The problem “Binary Tree to Binary Search Tree Conversion using STL set” asks to do conversion using STL set. We have already discussed converting the binary tree into BST but we ...

## Stack Questions Coursera

**Question 16. 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 ...

## Queue Questions Coursera

**Question 17. 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 ...

## Other Questions Coursera

**Question 18. Minimum Moves to Equal Array Elements Leetcode Solution** Problem Statement In this problem, we are given an array of integers. Also, we are allowed to perform a certain set of operations on this array. In one operation, we can increment ” n – 1″ (all elements except any one) elements in the array by 1. We need to ...