πŸ“˜
Placecom Question
  • βœ…ABC? (Contest)
  • βœ…Activity Selection (Contest)
  • βœ…Absolute value discrepancy (Contest)
  • βœ…Akash's Contest (Contest)
  • βœ…Alternate Matrix Addition(Contest)
  • βœ…Anti clockwise(Contest)
  • βœ…Arpit's toy (Contest)
  • βœ…Array Frequency Paradigm (Contest)
  • βœ…Array Games (Contest)
  • βœ…Arranging Students (Contest)
  • βœ…Array Proximity (Contest)
  • βœ…ATM Machine (Contest)
  • βœ…Awesome Numbers(Contest)
  • βœ…Bad Dish (Contest)
  • βœ…Balanced Neighborhood (Contest)
  • βœ…Birthday Gift (Contest)
  • βœ…Boundary Traversal of Matrix(Contest)
  • βœ…Buy and Sell Stock(Contest)
  • βœ…Cakewalk? (Contest)
  • βœ…Can we sort? (Contest)
  • βœ…Candy Love (Contest)
  • βœ…Candy Shopping (Contest)
  • βœ…Choose Card optimally(Contest)
  • βœ…Candy Store Earnings (Contest)
  • βœ…Choose points (Contest)
  • βœ…Concatenate Strings (Contest)
  • βœ…Common digits in two numbers (Contest)
  • βœ…Count 1's in binary array(Contest)
  • βœ…Count Numbers (Contest)
  • βœ…Count Total Digits in a Number (Contest)
  • βœ…Counting Zeroes to Ones (Contest)
  • βœ…Cyclic Rotation Paradigm (Contest)
  • βœ…Derrangement Exercise (Contest)
  • βœ…Diagonal Sum(Contest)
  • βœ…Diet planning (Contest)
  • βœ…Difference Array (Contest)
  • βœ…Digits Rearrangement (Contest)
  • ❌Divisible by 8 (Contest)
  • βœ…Door problem (Contest)
  • βœ…Duplicates at a distance k (Contest)
  • βœ…Easy - Peasy (Contest)
  • βœ…Eat or be Eaten(Contest)
  • βœ…Factorial - Recursion(Contest)
  • βœ…Find element in 2D array (Contest)
  • βœ…Generate all parentheses(Contest)
  • βœ…The gabba test(Contest)
  • βœ…Fruit Market (Contest)
  • βœ…Frequency Sort (Contest)
  • βœ…Floor in a Sorted Array(Contest)
  • βœ…First non-repeating character in a String(Contest)
  • βœ…Find unique(Contest)
  • βœ…Get the Shadow (Contest)
  • βœ…Good cells (Contest)
  • βœ…Good circular array (Contest)
  • βœ…Grid Magic (Contest)
  • βœ…Guardians of Galaxy(Contest)
  • βœ…Happy Balloons (Contest)
  • βœ…Help James (Contest)
  • βœ…Help Samar with Chopsticks (Contest)
  • βœ…Hip Hip Array (Contest)
  • βœ…Increment- Decrement Philosophy (Contest)
  • βœ…Infinity Stones : Form Black Order - The Army of Thanos (Contest)
  • βœ…Insert Operator(Contest)
  • βœ…Integer Modification (contest)
  • βœ…Inversion of array(Contest)
  • βœ…Iso Lexo String (Contest)
  • βœ…Jumping Numbers (Contest)
  • βœ…K closest points(Contest)
  • βœ…Knight game(Contest)
  • βœ…K-Pairs (Contest)
  • βœ…Kth Row of Pascal's Triangle(Contest)
  • βœ…Largest Bitonic Subarray(Contest)
  • βœ…Least Subarrays(Contest)
  • βœ…Lexographical Rotation (Contest)
  • βœ…Lone Sum Supremacy (Contest)
  • βœ…Lucky Boys(Contest)
  • ❌Majority Element(Contest)
  • βœ…Matrix problem(Contest)
  • βœ…Matrix ZigZag Traversal(Contest)
  • βœ…Max Candies(Contest)
  • βœ…Max permute (Contest)
  • βœ…Max Score in Quiz (Contest)
  • βœ…Max sum column (Contest)
  • βœ…Max XOR(Contest)
  • ❌Maximize Strength (Contest)
  • βœ…Maximizing Difference(Contest)
  • βœ…Maximum Area(Contest)
  • ❌Maximizing Difference(Contest)
  • βœ…Maximum Force(Contest)
  • βœ…Longest subarray not having more than K distinct elements(Contest)
  • βœ…Maximum value of difference of a pair of elements and their Index(Contest)
  • βœ…Minimum adjacent difference in a circular array easy(Contest)
  • βœ…Minimum Element in Sorted and Rotated Array(Contest)
  • βœ…Minimum operation - II(Contest)
  • βœ…Missing two(Contest)
  • βœ…Mohit and array(Contest)
  • βœ…Most occurring elements(Contest)
  • βœ…Move Zeros(Contest)
  • βœ…Moving right (Contest)
  • βœ…Max Score in Quiz (Contest)
  • βœ…N integers: Easy (Contest)
  • βœ…Nth node from end of linked list(Contest)
  • βœ…Number of distinct numbers(Contest)
  • βœ…Odd Sum Array (Contest)
  • βœ…Optimal Goodies (Contest)
  • βœ…Orange or Chocolate Candy? (Contest)
  • βœ…Packing Rectangles (Contest)
  • βœ…Pair sum (Contest)
  • βœ…Passcode (Contest)
  • βœ…Permutation - 2 (Contest)
  • βœ…Polynomial equation(Contest)
  • βœ…Power function(Contest)
  • βœ…Power of Three(Contest)
  • βœ…Print Pattern (Contest)
  • βœ…Reduce to 1 (Contest)
  • βœ…Remove Duplicates Inplace(Contest)
  • βœ…Repeating numbers (Contest)
  • βœ…Replace element(Contest)
  • βœ…Ropes (Contest)
  • βœ…Row Index Identification (Contest)
  • βœ…Row with maximum 1's(Contest)
  • βœ…Sara and Monsters (Contest)
  • βœ…Science Camp (contest)
  • βœ…Score bar(Contest)
  • βœ…Search in rotated sorted array(Contest)
  • βœ…Searching an element in a sorted array(Contest)
  • βœ…Separating Negative and Positive numbers(Contest)
  • ❌Sequence Formation (Contest)
  • ❌Setwet's Fish Pond(Contest)
  • βœ…Shopping (Contest)
  • βœ…Simple Circle (Simple Contest)
  • βœ…Simple Pairs(Contest)
  • βœ…Simple Transpose (Contest)
  • βœ…Skit Video (Contest)
  • βœ…Smaller elements (Contest)
  • βœ…Sort it (Contest)
  • βœ…Special digit sum (Contest)
  • βœ…Spiral rotation(Contest)
  • βœ…Squiggly brackets (Contest)
  • βœ…Strange element (Easy-Version)
  • βœ…Subarray with given sum(Contest)
  • βœ…Sum of largest elements(Contest)
  • βœ…Sum Up(Contest)
  • βœ…Swapping Matrix (Contest)
  • βœ…Sweet Bunty (Contest)
  • βœ…Teacher(Contest)
  • βœ…The EndGame : Concatenated Words(Contest)
  • βœ…The high median paradigm (Contest)
  • βœ…Tower of Hanoi(Contest)
  • βœ…Transpose of a matrix(Contest)
  • βœ…Triangular matrix (Contest)
  • βœ…Two Sum Maximization(Contest)
  • βœ…Ultron : Vibranium Quest(Contest)
  • βœ…Wakandan Point in Unsorted Array(Contest)
  • βœ…Yet again Partition sort problem (Contest)
  • βœ…Yet Another Array Rearrangement Problem (Contest)
  • βœ…Zero Padding(Contest)
  • βœ…First & Last (Contest)
  • ❌Fast Search (Contest)
Powered by GitBook
On this page

Kth Row of Pascal's Triangle(Contest)

Kth Row of Pascal's Triangle easy Time Limit: 2 sec Memory Limit: 128000 kB

PreviousK-Pairs (Contest)NextLargest Bitonic Subarray(Contest)

Last updated 2 years ago

Problem Statement :

Given an index K, return the K-th row of . You must print the K-th row modulo 109 + 7. The rows of Pascal's triangle are conventionally enumerated starting with row K=0 at the top (the 0th row)InputThe only line of input contains the input K. Constraints:- 0 ≀ K ≀ 3000 OutputPrint k-th row of Pascal's Triangle containing k+1 integers modulo 10^9+7.ExampleSample Input : 3 Sample Output: 1 3 3 1

link:

```java
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
   public static final int mod = 1000000007;

    public static int add(int a, int b) {
        int res = a + b;
        if (res >= mod) {
            res -= mod;
        }
        return res;
    }

    public static int sub(int a, int b) {
        int res = a - b;
        if (res < 0) {
            res += mod;
        }
        return res;
    }

    public static int mul(int a, int b) {
        return (int) ((long) a * b % mod);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayList<Integer> row = new ArrayList<>(k + 1);
        row.add(1);
        for (int i = 1; i <= k; i++) {
            int n = row.size();
            for (int j = n - 2; j >= 0; j--) {
                row.set(j + 1, add(row.get(j), row.get(j + 1)));
            }
            row.add(1);
        }
        for (int i = 0; i <= k; i++) {
            System.out.print(row.get(i) + " ");
        }
    }
}
```
βœ…
Pascal’s triangle
https://my.newtonschool.co/playground/code/ynuml7qftqz8/