Skip to content

Comments

Generate parentheses#38

Open
atig05 wants to merge 7 commits intoPriyanshuChatterjee:mainfrom
atig05:generate-parentheses
Open

Generate parentheses#38
atig05 wants to merge 7 commits intoPriyanshuChatterjee:mainfrom
atig05:generate-parentheses

Conversation

@atig05
Copy link
Contributor

@atig05 atig05 commented Oct 28, 2021

//You are given a number n
//you have to print all valid combinations that can be made using n pairs of brackets

example:
Input:
N = 3
Output:
((()))
(()())
(())()
()(())
()()()

atig05 added 7 commits October 4, 2021 09:47
find the maximum and minimum elements of an array using divide and conquer method
Consider a rat placed at (0, 0) in a square matrix of order N * N. It has to reach the destination at (N - 1, N - 1). Find all possible paths that the rat can take to reach from source to destination. The directions in which the rat can move are 'U'(up), 'D'(down), 'L' (left), 'R' (right). Value 0 at a cell in the matrix represents that it is blocked and rat cannot move to it while value 1 at a cell in the matrix represents that rat can be travel through it.
Note: In a path, no cell can be visited more than one time.

Example1
Input:
N = 4
m[][] = {{1, 0, 0, 0},
         {1, 1, 0, 1}, 
         {1, 1, 0, 0},
         {0, 1, 1, 1}}
Output:
DDRDRR DRDDRR
Explanation:
The rat can reach the destination at 
(3, 3) from (0, 0) by two paths - DRDDRR 
and DDRDRR, when printed in sorted order 
we get DDRDRR DRDDRR.
Consider a rat placed at (0, 0) in a square matrix of order N * N. It has to reach the destination at (N - 1, N - 1). Find all possible paths that the rat can take to reach from source to destination. The directions in which the rat can move are 'U'(up), 'D'(down), 'L' (left), 'R' (right). Value 0 at a cell in the matrix represents that it is blocked and rat cannot move to it while value 1 at a cell in the matrix represents that rat can be travel through it.
Note: In a path, no cell can be visited more than one time.

Example:
Input:
N = 4
m[][] = {{1, 0, 0, 0},
         {1, 1, 0, 1}, 
         {1, 1, 0, 0},
         {0, 1, 1, 1}}
Output:
DDRDRR DRDDRR
Explanation:
The rat can reach the destination at 
(3, 3) from (0, 0) by two paths - DRDDRR 
and DDRDRR, when printed in sorted order 
we get DDRDRR DRDDRR.
The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other.
This code takes the number of queens and outputs the possible solutions
//You are given a number n
//you have to print all valid combinations that can be made using n pairs of brackets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant