Skip to main content

Posts

Showing posts with the label Pascal triangle

Pascal's Triangle [EASY/IMP]

Company:Adobe Question:  Given an integer K,return the kth row of pascal triangle. Pascal's triangle is a triangular array of the binomial coefficients formed by summing up the elements of previous row. Example of pascal triangle: 1 1 1 1 2 1 1 3 3 1   for K=3, return 3rd row i.e 1 2 1   Input: The first line contains an integer T,depicting total number of test cases.  Then following T lines contains an integer N depicting the row of triangle to be printed. Output: Print the Nth row of triangle in a separate line. Constraints: 1 ≤ T ≤ 50 1 ≤ N ≤ 25 Example: Input 1 4 Output 1 3 3 1 CODE: import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; class GFG { public static void main (String[] args) { Scanner sc = new Scanner (System.in); int m = sc.nextInt(); for(int mi=0;mi<m;mi++){    int n= sc.nextInt();      for(int r=0;r...