## Subset Sum Problem | DP-25

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given… Read More »

- Find the smallest positive number missing from an unsorted array | Set 3
- Remove duplicates from unsorted array using Set data structure
- Find the minimum number of moves to reach end of the array
- Sum of digits with even number of 1's in their binary representation
- Minimum number of Fibonacci jumps to reach end
- Calculate height of Binary Tree using Inorder and Level Order Traversal
- Reduce number to a single digit by subtracting adjacent digits repeatedly
- Count smaller elements on right side and greater elements on left side using Binary Index Tree
- Find minimum changes required in an array for it to contain k distinct elements
- Maximum subsequence sum such that all elements are K distance apart
- Make the list non-decreasing by changing only one digit of the elements
- Queries for number of distinct elements in a subarray | Set 2
- Sort an array of strings according to string lengths using Map
- Count of triplets that satisfy the given equation
- Number of Subsequences with Even and Odd Sum
- Find number of triplets in array such that a[i]>a[j]>a[k] and i<j<k
- Find the sum of all possible pairs in an array of N elements
- Find the winner of the match | Multiple Queries
- Find subarray with given sum with negatives allowed in constant space
- Sum of the sums of all possible subsets
- Minimum number of Bottles visible when a bottle can be enclosed inside another Bottle
- Subsequence X of length K such that gcd(X[0], X[1]) + (X[2], X[3]) + ... is maximized
- Optimal Strategy for a Game | Set 3
- Merge two sorted arrays in constant space using Min Heap
- Find the Majority Element | Set 3 (Bit Magic)
- Queries to check whether all the elements in the given range occurs even number of times
- Count number of ways to get Odd Sum
- Divide an array into K subarray with the given condition
- Length of longest subarray in which elements greater than K are more than elements not greater than K
- Find a pair (n,r) in an integer array such that value of nPr is maximum

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given… Read More »

There was 1 online coding round, followed by interviews. Online coding round was on Codechef. 1st question Sandeep and Pali want to go on holiday.… Read More »

Written Round: 1) Given a binary tree, such that each node contains a number. Find the maximum possible sum in going from one leaf node… Read More »

Write code to convert a given number into words. For example, if “1234” is given as input, output should be “one thousand two hundred thirty… Read More »

In my previous post, I have explained about longest increasing sub-sequence (LIS) problem in detail. However, the post only covered code related to querying size of… Read More »

Pascal’s triangle is a triangular array of the binomial coefficients. Write a function that takes an integer value n as input and prints first n… Read More »

Given two numbers represented by two linked lists, write a function that returns the sum list. The sum list is linked list representation of the… Read More »

Given an unsorted array of positive integers. Find the number of triangles that can be formed with three different array elements as three sides of… Read More »

Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity… Read More »

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. Example: Input matrix 0 1 1… Read More »

Given n numbers (both +ve and -ve), arranged in a circle, fnd the maximum sum of consecutive number. Examples: Input: a[] = {8, -8, 9,… Read More »

Given a number, find the next smallest palindrome larger than this number. For example, if the input number is “2 3 5 4 5”, the… Read More »

Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n… Read More »

Given an array of integers, find any one combination of four elements in the array whose sum is equal to a given value X. For… Read More »

Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. For example,… Read More »