{"id":"521392aa-ab96-40d6-b56d-609149099026","name":"Queens Combinations - 2d As 1d - Queen Chooses","description":"1. You are given a number n, representing the size of a n * n chess board.\r\n2. You are required to calculate and print the combinations in which n queens can be placed on the \r\n n * n chess-board. \r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't \r\n force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= n &lt;= 5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvoid nqueens(int qpsf , int tq , vector<vector<bool>> &chess , int lcno)\n{\n //Write your code here\n}\nint main(){\n int n ;\n cin>>n ;\n vector<vector<bool>> chess(n , vector<bool>(n,false)) ;\n nqueens(0 , n , chess , -1) ;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensCombinations(int qpsf, int tq, boolean[][] chess, int lcno) {\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n boolean[][] chess = new boolean[n][n];\r\n\r\n queensCombinations(0, n, chess, -1);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2","sampleOutput":"q\tq\t\r\n-\t-\t\r\n\r\nq\t-\t\r\nq\t-\t\r\n\r\nq\t-\t\r\n-\tq\t\r\n\r\n-\tq\t\r\nq\t-\t\r\n\r\n-\tq\t\r\n-\tq\t\r\n\r\n-\t-\t\r\nq\tq\t\r\n\r\n","questionVideo":"https://www.youtube.com/embed/35JK-scUhpw?end=423","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"e0dbdf86-6bac-490a-b6c5-47421f123788","name":"Queens Combinations - 2d As 1d - Queen Chooses","slug":"queens-combinations-2d-as-1d-queen-chooses","type":1}],"next":{"id":"d97a0abc-6632-4c3b-94b9-48129c61601c","name":"Queens Combinations - 2d As 1d - Queen Chooses MCQ","type":0,"slug":"queens-combinations-2d-as-1d-queen-chooses-mcq"},"prev":{"id":"58c854fb-72ed-4419-af18-a8f7663ed069","name":"Queens Combinations - 2d As 2d - Queens Chooses MCQ","type":0,"slug":"queens-combinations-2d-as-2d-queens-chooses-mcq"}}}

Queens Combinations - 2d As 1d - Queen Chooses

1. You are given a number n, representing the size of a n * n chess board. 2. You are required to calculate and print the combinations in which n queens can be placed on the n * n chess-board. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

{"id":"521392aa-ab96-40d6-b56d-609149099026","name":"Queens Combinations - 2d As 1d - Queen Chooses","description":"1. You are given a number n, representing the size of a n * n chess board.\r\n2. You are required to calculate and print the combinations in which n queens can be placed on the \r\n n * n chess-board. \r\n\r\nNote -> Use the code snippet and follow the algorithm discussed in question video. The judge can't \r\n force you but the intention is to teach a concept. Play in spirit of the question.","inputFormat":"A number n","outputFormat":"Check the sample output and question video","constraints":"1 &lt;= n &lt;= 5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvoid nqueens(int qpsf , int tq , vector<vector<bool>> &chess , int lcno)\n{\n //Write your code here\n}\nint main(){\n int n ;\n cin>>n ;\n vector<vector<bool>> chess(n , vector<bool>(n,false)) ;\n nqueens(0 , n , chess , -1) ;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void queensCombinations(int qpsf, int tq, boolean[][] chess, int lcno) {\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r\n int n = Integer.parseInt(br.readLine());\r\n boolean[][] chess = new boolean[n][n];\r\n\r\n queensCombinations(0, n, chess, -1);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"2","sampleOutput":"q\tq\t\r\n-\t-\t\r\n\r\nq\t-\t\r\nq\t-\t\r\n\r\nq\t-\t\r\n-\tq\t\r\n\r\n-\tq\t\r\nq\t-\t\r\n\r\n-\tq\t\r\n-\tq\t\r\n\r\n-\t-\t\r\nq\tq\t\r\n\r\n","questionVideo":"https://www.youtube.com/embed/35JK-scUhpw?end=423","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"e0dbdf86-6bac-490a-b6c5-47421f123788","name":"Queens Combinations - 2d As 1d - Queen Chooses","slug":"queens-combinations-2d-as-1d-queen-chooses","type":1}],"next":{"id":"d97a0abc-6632-4c3b-94b9-48129c61601c","name":"Queens Combinations - 2d As 1d - Queen Chooses MCQ","type":0,"slug":"queens-combinations-2d-as-1d-queen-chooses-mcq"},"prev":{"id":"58c854fb-72ed-4419-af18-a8f7663ed069","name":"Queens Combinations - 2d As 2d - Queens Chooses MCQ","type":0,"slug":"queens-combinations-2d-as-2d-queens-chooses-mcq"}}}
plane

Editor


Loading...

Queens Combinations - 2d As 1d - Queen Chooses

medium

1. You are given a number n, representing the size of a n * n chess board. 2. You are required to calculate and print the combinations in which n queens can be placed on the n * n chess-board. Note -> Use the code snippet and follow the algorithm discussed in question video. The judge can't force you but the intention is to teach a concept. Play in spirit of the question.

Constraints

1 <= n <= 5

Format

Input

A number n

Output

Check the sample output and question video

Example

Sample Input

2

Sample Output

q q - - q - q - q - - q - q q - - q - q - - q q

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode