## Find the repeating and missing numbers

[Question]:Given an unsorted array of size n. Array elements are in the range of 1 to n. One number from set {1, 2, …n} is missing and one number occurs twice in the array. Find these two numbers.Input: arr[] = {3, 1, 3}Output: Missing = 2, Repeating = 3Explanation: In the array, 2 is missing and 3 occurs …

## Merge two Sorted Arrays Without Extra Space

[Question]: Given two sorted arrays arr1[] and arr2[] ofsizes n and m in non-decreasing order. Merge them in sorted order without using any extra space. Modify arr1 so that it contains the first N elements and modify arr2 so that it contains the last M elements. Example 1: Input: n = 4, arr1[] = [1 3 5 7] m = 5, arr2[] = …

## Merge all overlapping intervals

[Question]: Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.Example: – Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlap, merge them into [1,6]. Constraints: 1 <= intervals.length <= 104 intervals[i].length == 2 0 <= …

## Count the number of subarrays with given xor K

[Question]: Problem Statement: Given an array of integers A and an integer B. Find the total number of subarrays having bitwise XOR of all elements equal to k.Example 1:Input Format: A = [4, 2, 2, 6, 4] , k = 6Result: 4Explanation: The subarrays having XOR of their elements as 6 are [4, 2], [4, 2, …

## Why extensions must not contain stored properties?

In Programming language principal generally we consider State & Behaviour State can be consider as properties(let, var) & Behaviour as Functions. For example: – dog, cat, and vehicle. To illustrate, a dog has states like age, color, name, and behaviours like eating, sleeping, and running. State tells us how the object looks or what properties …

## Length of the longest subarray with zero Sum

[Question]: Problem Statement: Given an array containing both positive and negative integers, we have to find the length of the longest subarray with the sum of all elements equal to zero.Input array = [9, -3, 3, -1, 6, -5]Result: 5Explanation: The following subarrays sum to zero:{-3, 3} , {-1, 6, -5}, {-3, 3, -1, 6, -5}Since …

## 4 Sum | Find Quads that add up to a target value4 Sum

[Question]: Find Quads that add up to a target value4 Sum Approach# using the 4 pointers Two pointers a & b are fixed and we have two moving pointers c and d. where c starts from b + 1 and d is start from last index Complexity Analysis Time Complexity: O(N3), where N = size of …

## 3 Sum : Find triplets that add up to a zero

[Question]: Find triplets that add up to a zero (3 sum) Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation: nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0. nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0. nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) …

## Find all elements that appear more than ⌊ n/3 ⌋ times.

[Question]: Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.Example: Input =  [11, 33, 33, 11, 33, 11]; Output:–// [11,33] Approach: By using dictionary

## Find next lexicographically greater permutation

[Question]: A permutation of an array of integers is an arrangement of its members into a sequence or linear order.For example, for array = [1,2,3], the following are all the permutations of array: [1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]