## 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 »

## Directi Interview | Set 2

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 »

## Directi Interview | Set 1

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 »

## Program to convert a given number to words

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 »

## Construction of Longest Increasing Subsequence (N log N)

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

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 »

## Add two numbers represented by linked lists | Set 2

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 »

## Count the number of possible triangles

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 »

## Find the element that appears once

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 »

## Find the row with maximum number of 1s

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 »

## Maximum circular subarray sum

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

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 »

## Sort a nearly sorted (or K sorted) array

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 »

## Find four elements that sum to a given value | Set 2 ( O(n^2Logn) Solution)

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 »

## Find four elements that sum to a given value | Set 1 (n^3 solution)

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 »