`{"id":"398db491-99b6-40a9-a338-103b96dc2f6e","name":"Pascal's Triangle 2","description":"Description : \r\n1. Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.\r\n2. In Pascal's triangle, each number is the sum of the two numbers directly above OR it is also a pattern which can be made from combination maths\r\n3. For More clearance, watch video till explanation of question.\r\neg. \r\nrow 0 -> 1\r\nrow 1 -> 1 1\r\nrow 2 -> 1 2 1\r\nrow 3 -> 1 3 3 1\r\nrow 4 -> 1 4 6 4 1\r\n","inputFormat":"rowIndex = 3\r\n","outputFormat":"1 3 3 1","constraints":"1. 0 &lt;= rowIndex &lt;= 33\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> pascalRow(int r)\n{\n //write your code here\n}\n\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> res = pascalRow(n);\n \n for(int val : res)\n {\n cout<<val<<\" \";\n }\n cout<<endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~User Section~~~~~~~~~~~~~~~~\r\n public static ArrayList<Integer> pascalRow(int r) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~Input management~~~~~~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n ArrayList<Integer> res = pascalRow(n);\r\n for (int val : res) {\r\n System.out.print(val + \" \");\r\n }\r\n System.out.println();\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"1 3 3 1 ","questionVideo":"","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":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"205865a8-f7e5-4945-8df6-3bcf9e4d9546","name":"Pascal's Triangle 2","slug":"pascal-s-triangle-2","type":1}],"next":{"id":"9e22619b-a250-4837-81b0-8d824ac51546","name":"Pascal's Triangle 2","type":3,"slug":"pascal-s-triangle-2"},"prev":{"id":"c40483c8-348a-4123-87df-502a3ef8e76b","name":"Sum Of Subsequence Widths MCQ","type":0,"slug":"sum-of-subsequence-widths-mcq"}}}`

# Pascal's Triangle 2

Description : 1. Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. 2. In Pascal's triangle, each number is the sum of the two numbers directly above OR it is also a pattern which can be made from combination maths 3. For More clearance, watch video till explanation of question. eg. row 0 -> 1 row 1 -> 1 1 row 2 -> 1 2 1 row 3 -> 1 3 3 1 row 4 -> 1 4 6 4 1

`{"id":"398db491-99b6-40a9-a338-103b96dc2f6e","name":"Pascal's Triangle 2","description":"Description : \r\n1. Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.\r\n2. In Pascal's triangle, each number is the sum of the two numbers directly above OR it is also a pattern which can be made from combination maths\r\n3. For More clearance, watch video till explanation of question.\r\neg. \r\nrow 0 -> 1\r\nrow 1 -> 1 1\r\nrow 2 -> 1 2 1\r\nrow 3 -> 1 3 3 1\r\nrow 4 -> 1 4 6 4 1\r\n","inputFormat":"rowIndex = 3\r\n","outputFormat":"1 3 3 1","constraints":"1. 0 &lt;= rowIndex &lt;= 33\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvector<int> pascalRow(int r)\n{\n //write your code here\n}\n\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> res = pascalRow(n);\n \n for(int val : res)\n {\n cout<<val<<\" \";\n }\n cout<<endl;\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~User Section~~~~~~~~~~~~~~~~\r\n public static ArrayList<Integer> pascalRow(int r) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~Input management~~~~~~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n ArrayList<Integer> res = pascalRow(n);\r\n for (int val : res) {\r\n System.out.print(val + \" \");\r\n }\r\n System.out.println();\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"3","sampleOutput":"1 3 3 1 ","questionVideo":"","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":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"205865a8-f7e5-4945-8df6-3bcf9e4d9546","name":"Pascal's Triangle 2","slug":"pascal-s-triangle-2","type":1}],"next":{"id":"9e22619b-a250-4837-81b0-8d824ac51546","name":"Pascal's Triangle 2","type":3,"slug":"pascal-s-triangle-2"},"prev":{"id":"c40483c8-348a-4123-87df-502a3ef8e76b","name":"Sum Of Subsequence Widths MCQ","type":0,"slug":"sum-of-subsequence-widths-mcq"}}}`

Editor

# Pascal's Triangle 2

easy

Description : 1. Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. 2. In Pascal's triangle, each number is the sum of the two numbers directly above OR it is also a pattern which can be made from combination maths 3. For More clearance, watch video till explanation of question. eg. row 0 -> 1 row 1 -> 1 1 row 2 -> 1 2 1 row 3 -> 1 3 3 1 row 4 -> 1 4 6 4 1

## Constraints

1. 0 <= rowIndex <= 33

rowIndex = 3

1 3 3 1

## Example

Sample Input

`.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}3`

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}1 3 3 1 `

Discussions

Show Discussion

Related Resources