## Find all unique combinations of numbers (from 1 to 9 ) with sum to N

Objective: Given an integer N, Write an algorithm to select numbers from 1 to 9 and make combinations such that its sum to N. Example: N= 5 Output: [1, 4] [2, 3] [5] N...

@tutorialhorizon

Objective: Given an integer N, Write an algorithm to select numbers from 1 to 9 and make combinations such that its sum to N. Example: N= 5 Output: [1, 4] [2, 3] [5] N...

Objective: Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of distinct or unique islands. Island: An island is surrounded by water and is formed by connecting adjacent lands...

Objective: Given a two-dimensional array or matrix, Do the depth-First Search (DFS) to print the elements of the given matrix. Implement the Depth-first traversal in a recursive manner. Example: int [][] grid = new...

Objective: Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Assume...

Objective: Given a number N, write an algorithm to find the maximum number of steps it takes to transform (1, N) to 1 using Collatz Conjecture. The Collatz conjecture is a conjecture in mathematics...

Objective: Given a stack, write a program to print the stack elements in reverse order. Example: Approach: Use Temporary stack: Take temporary stack, and copy all the items from the given stack to a...

Objective: Given an array of numbers, write an algorithm to print all the subsets sum individually. Example: Given Input: [1, 2] Output: 3 1 2 0 Explanation: subsets are [0], [1], [2], [1, 2]...

Objective: Given two integers N and K. Write an algorithm to find all the combinations of k numbers which sum to N. Conditions: All K numbers must be between 1 and 9 and unique....

Objective: Given an array of integers write an algorithm to find all the subsets for which sum is equal to zero. The array contains both positive and negative integers. Example: Given Array: [8, 3,...

Objective: Given a number N, write an algorithm to convert that number to 1. Below are the allowed operations. If N is even, do N = N/2. If N is odd, either do N...

Problem Statement: When customers book an Airbnb the total price, which includes base price + service fee + cleaning fee. all these prices are in decimals. Write an algorithm to round each price such...

Objective: Given a Stack, write an algorithm to reverse the stack. Example: Original Stack: [14, 9, 67, 91, 101, 25] Reversed Stack: [25, 101, 91, 67, 9, 14] Approach: Use Recursion In this solution,...

The Collatz conjecture is a conjecture in mathematics which states that no matter what value of Positive Number N, If the below sequence is followed then, the sequence will always reach 1. If N...

Objective: Given a number, write a java program to reverse a number Example: Given Number: 1234 Output: 4321 Given Number: 1020 Output: 201 Approach: Using loop Keep divide the number by 10 and add...

%d bloggers like this: