## Dynamic Programming – Stairs Climbing Puzzle

Objective: A child is climbing up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways...

## Dynamic Programming – Minimum Coin Change Problem

Objective: Given a amount ‘A’ and n coins,   v1<v2<v3<………..<vn . Write a program to find out minimum numbers of coins required to make the change for the amount ‘A’. Example: Amount: 5 Coins []...

## Merge K Sorted Arrays

Objective: Given k sorted array, write an algorithm to merge Them into One sorted array. Example : int[][] A = new int[]; A = new int[] { 1, 5, 8, 9 }; A =...

## Diameter Of a Binary Tree

Objective: – Given a binary tree, write an algorithm to find the diameter of the tree. What is Diameter Of a Tree: Diameter of tree is defined as A longest path or route between...

## Find the Height of a tree without Recursion

Objective: – Find the Height of a tree without Recursion. In our earlier post “Height of tree” we had used recursion to find it. In this post we will see how to find it...

## Print All the Subsets of a Given Set (Power Set)

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S...

## Print All Combinations of subset of size K from Given Array

Objective: Given an array of integers of size N, print all the subsets of size k. (k<=N) Example: Generate all subsets of a fixed size k of a given set [1,2,3…n]. e.g, if n=5...

## Print All Possible Valid Combinations Of Parenthesis of Given ‘N’

Objec­tive: – Given “n”, generate all valid parenthesis strings of length “2n”. Example: Given n=2 Output: (()) ()() Approach:

## Implement Queue Using Stacks

Objective: We know that Queue is FIFO (First-in-First-Out) and Stack is LIFO ( Last-in-First-Out). Here our objective is to implement queue using stacks. Approach: Take 2 Stacks, stack1 and stack2. stack1 will be used...

## Merge Sort in a Linked list

Objective: Given a Linked List, Sort it using merge sort. Example: ->9->3->4->2->5->1 Sorted List: ->1->2->3->4->5->9 Approach: Reference : Merge Sort in array As it Merge sort, we apply the same logic , Divide and...

## Construct Binary Search Tree from a given Preorder Traversal Using Stack (Without Recursion)

Objective: – Given a preorder traversal, construct BST from that, without using recursion. Input: Preorder traversal Similar Problem : This problem is similar to the Construct Binary Search Tree from a given Preorder Traversal...

## Construct Binary Search Tree from a given Preorder Traversal using Recursion

Objective: – Given a preorder traversal, construct BST from that. Input: Preorder traversal Similar Problem : This problem is similar to the – Construct Binary Search Tree from a given Preorder Traversal Using Stack...

## In an Array, find the Smallest Subarray with Sum Greater than the Given Value

Objective: Given an array and an integer, find the smallest subarray whose sum is greater than the given integer. Examples: arrA[] = { 1, 5, 20, 70, 8} Integer = 97 Output : Min...

## Find All Elements in an Array which appears more than N/K times, N is Array Size and k is a Number.

Objective: Given an array of size of N and number k. Find all elements in an Array which appears more than N/K times. Input: Array [] and number k. Example: int[] arrA = {...

## Print All The Nodes Which are X distance from the Given Node

Objective: – Given Binary Tree, Print All The Nodes Which are X distance from the Given Node. Example : Approach: Quite Tricky solution, i will explain using the example given in the picture.
{"ft_lang_label":"__label__en","ft_lang_prob":0.805097,"math_prob":0.8711751,"size":3030,"snap":"2020-24-2020-29","text_gpt3_token_len":762,"char_repetition_ratio":0.14243226,"word_repetition_ratio":0.18490566,"special_character_ratio":0.27656767,"punctuation_ratio":0.21354933,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9974073,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-03T12:47:24Z\",\"WARC-Record-ID\":\"<urn:uuid:e25c43a2-471d-4cb4-9f49-c020b9c02683>\",\"Content-Length\":\"181514\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0d0e27c5-7e7e-42fe-b51b-455315c01fa6>\",\"WARC-Concurrent-To\":\"<urn:uuid:17ecb12f-4b8c-4cde-b38c-2f2530f137ca>\",\"WARC-IP-Address\":\"104.18.45.129\",\"WARC-Target-URI\":\"https://algorithms.tutorialhorizon.com/category/top-companies/facebook/page/4/\",\"WARC-Payload-Digest\":\"sha1:CKO34DCPR533POAYBWBL4BP2A5BNRMU6\",\"WARC-Block-Digest\":\"sha1:Z725GNJ7GJ3HFTTI6OGQCTNEIMOB3NV3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347434137.87_warc_CC-MAIN-20200603112831-20200603142831-00366.warc.gz\"}"}