{"id":"b3f10306-0f77-49c3-9bfe-61d8d35b3d3b","name":"Friends Pairing - 2","description":"1. You are given an integer n, which represents n friends numbered from 1 to n.\r\n2. Each one can remain single or can pair up with some other friend.\r\n3. You have to print all the configurations in which friends can remain single or can be paired up.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A number n","outputFormat":"Check the sample ouput and question video.","constraints":"1 <= n <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n static int counter = 1;\r\n\r\n public static void solution(int i, int n, boolean[] used, String asf) {\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n Scanner sc = new Scanner(System.in);\r\n int n = sc.nextInt();\r\n boolean[] used = new boolean[n + 1];\r\n solution(1, n, used, \"\");\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"1.(1) (2) (3) \r\n2.(1) (2,3) \r\n3.(1,2) (3) \r\n4.(1,3) (2) \r\n","questionVideo":"https://www.youtube.com/embed/qv_1Pstbm-w?end=124","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":"beed9bc6-e89e-4360-afa8-0f241b39a35d","name":"Friends Pairing - 2","slug":"friends-pairing-2","type":1}],"next":{"id":"d05856db-a2fe-40f4-8ec0-9854fc499074","name":"Friends Pairing-2 MCQ","type":0,"slug":"friends-pairing-2-mcq"},"prev":{"id":"b5d0a796-2e3d-4d65-bf91-eec3f50cebad","name":"Cryptarithmetic MCQ","type":0,"slug":"cryptarithmetic-mcq"}}}

Friends Pairing - 2

1. You are given an integer n, which represents n friends numbered from 1 to n. 2. Each one can remain single or can pair up with some other friend. 3. You have to print all the configurations in which friends can remain single or can be paired up. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

{"id":"b3f10306-0f77-49c3-9bfe-61d8d35b3d3b","name":"Friends Pairing - 2","description":"1. You are given an integer n, which represents n friends numbered from 1 to n.\r\n2. Each one can remain single or can pair up with some other friend.\r\n3. You have to print all the configurations in which friends can remain single or can be paired up.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A number n","outputFormat":"Check the sample ouput and question video.","constraints":"1 <= n <= 10","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n static int counter = 1;\r\n\r\n public static void solution(int i, int n, boolean[] used, String asf) {\r\n // write your code here\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n Scanner sc = new Scanner(System.in);\r\n int n = sc.nextInt();\r\n boolean[] used = new boolean[n + 1];\r\n solution(1, n, used, \"\");\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"1.(1) (2) (3) \r\n2.(1) (2,3) \r\n3.(1,2) (3) \r\n4.(1,3) (2) \r\n","questionVideo":"https://www.youtube.com/embed/qv_1Pstbm-w?end=124","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":"beed9bc6-e89e-4360-afa8-0f241b39a35d","name":"Friends Pairing - 2","slug":"friends-pairing-2","type":1}],"next":{"id":"d05856db-a2fe-40f4-8ec0-9854fc499074","name":"Friends Pairing-2 MCQ","type":0,"slug":"friends-pairing-2-mcq"},"prev":{"id":"b5d0a796-2e3d-4d65-bf91-eec3f50cebad","name":"Cryptarithmetic MCQ","type":0,"slug":"cryptarithmetic-mcq"}}}
plane

Editor


Loading...

Friends Pairing - 2

easy

1. You are given an integer n, which represents n friends numbered from 1 to n. 2. Each one can remain single or can pair up with some other friend. 3. You have to print all the configurations in which friends can remain single or can be paired up. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

Constraints

1 <= n <= 10

Format

Input

A number n

Output

Check the sample ouput and question video.

Example

Sample Input

3

Sample Output

1.(1) (2) (3) 2.(1) (2,3) 3.(1,2) (3) 4.(1,3) (2)

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode