Nizamuddin Siddiqui has Published 2307 Articles

How to find all the different combinations of opening and closing brackets from the given number k using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:40:18

284 Views

Create a backtrack function that updates the current string if open brackets are less than n or close bracket are less than open bracket. When the length of current string becomes equal to 2*n, add it to the combination result array. It could be simply tracked by keeping the number ... Read More

How to find the unique combination of sum from the given number C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:32:02

275 Views

Create an output list to store the valid sequences, create a current list that will store the current sequence found in the path of the recursion tree. A backtrack function that will go into the recursion until the target is achieved, otherwise, it should backtrack to the previous phase as ... Read More

How to find the unique combination k sum that corresponds to k sum using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:27:29

188 Views

Create an output list to store the valid sequences, create a current list that will store the current sequence found in the path of the recursion tree. A backtrack function that will go into the recursion until the target is achieved, otherwise, it should backtrack to the previous phase as ... Read More

How to find the distinct subsets from a given array by backtracking using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:24:48

313 Views

Distinct subsets problem gives us the different combination from the given array.When the target is 2 then from the array, we take all the combination that corresponds to number 2, When the target is three then from the array, we take all the combination that corresponds to count 3. In ... Read More

How to find the target sum from the given array by backtracking using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:22:21

433 Views

Target sum problem is the problem of finding a subset such that the sum of elements equal a given number. The backtracking approach generates all permutations in the worst case but in general, performs better than the recursive approach towards subset sum problem.A subset A of n positive integers and ... Read More

How to get all the combinations of the keypad value in a mobile by backtracking using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:19:16

217 Views

The problem can be broken down into smaller and simple "subproblems", which can be further divided into yet simpler and smaller subproblems. We take each and every digit one by one and count all ndigits reachable from any digit, use a map to store the mapping of digits reachable from ... Read More

How to find all the permutation of the string by backtracking using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:15:22

643 Views

Find the character in the first position and swap the rest of the character with the first character. Like in ABC, in the first iteration three strings are formed: ABC, BAC, and CBA by swapping A with A, B and C respectively. Repeat step for the rest of the characters ... Read More

How to find the power of any given number by backtracking using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:13:10

271 Views

Create a function to Find Power which takes the number x and n, where x is the 2 and n is how many times, we have to do the power. If the number is even then we have to do x*x and if the number is odd multiply the result ... Read More

How to print number of islands in a given matrix using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:11:51

480 Views

Linear scan the 2d grid map, if a node contains a '1', then it is a root node that triggers a Depth First Search. During DFS, every visited node should be set as '0' to mark as visited node. Count the number of root nodes that trigger DFS, this number ... Read More

How to print a matrix of size n*n in spiral order using C#?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 27-Aug-2021 13:09:07

757 Views

To rotate a matrix in spiral order, we need to do following until all the inner matrix and the outer matrix are covered −Step1 − Move elements of top rowStep2 − Move elements of last columnStep3 − Move elements of bottom rowStep4 − Move elements of first columnStep5 − Repeat ... Read More

Advertisements