Uncategorized

Number of Increasing Paths in a Grid solution leetcode

Number of Increasing Paths in a Grid solution leetcode Solution – CLICK HERE You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions. Return the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may be very large, return it modulo 109 + …

Number of Increasing Paths in a Grid solution leetcode Read More »

Number of People Aware of a Secret solution leetcode

Number of People Aware of a Secret solution leetcode Solution – CLICK HERE On day 1, one person discovers a secret. You are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days …

Number of People Aware of a Secret solution leetcode Read More »

Spiral Matrix IV solution leetcode

Spiral Matrix IV solution leetcode Solution – CLICK HERE You are given two integers m and n, which represent the dimensions of a matrix. You are also given the head of a linked list of integers. Generate an m x n matrix that contains the integers in the linked list presented in spiral order (clockwise), starting from the top-left of the matrix. If there are remaining empty spaces, …

Spiral Matrix IV solution leetcode Read More »

Decode the Message solution leetcode

Decode the Message solution leetcode Solution – CLICK HERE You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows: Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table. Align the substitution table with the regular English alphabet. Each letter in message is then substituted using …

Decode the Message solution leetcode Read More »

Strong Elements solution codechef

Strong Elements solution codechef Chef has an array AA of length NN. An index ii is called strong if we can change the gcd of the whole array just by changing the value of AiAi. Determine the number of strong indices in the array. Input Format First line will contain TT, number of test cases. Then the test cases follow. First line of each test case contains an …

Strong Elements solution codechef Read More »

Ambiguous Dominoes solution codeforces

Polycarp and Monocarp are both solving the same puzzle with dominoes. They are given the same set of n dominoes, the i-th of which contains two numbers xi and yi. They are also both given the same m by k grid of values aij such that ⋅=2m⋅k=2n. Ambiguous Dominoes solution codeforces The puzzle asks them to place the n dominoes on the grid in such a way that none of …

Ambiguous Dominoes solution codeforces Read More »

Dearrange sorting solution codechef

Dearrange sorting solution codechef You are given a permutation PP of length NN. A permutation of length NN is an array where every element from 11 to NN occurs exactly once. You must perform some operations on the array to make it sorted in increasing order. In one operation, you must: Select two indices LL and RR (1≤L<R≤N)(1≤L<R≤N) Completely dearrange the subarray PL,PL+1,…PRPL,PL+1,…PR A dearrangement of an array AA is any permutation BB of AA for which Bi≠AiBi≠Ai for …

Dearrange sorting solution codechef Read More »

Is this priority or parity! solution codechef

Is this priority or parity! solution codechef NN integers 1,2,3,…N1,2,3,…N are placed on a circle in clockwise order such that ii and (i+1)(i+1) are adjacent for all 1≤i≤N−11≤i≤N−1, and 11 and NN are also adjacent. Given an integer KK, Ashish repeatedly removes integers from the circle until only one integer remains. He does so in the following manner. In each move, Ashish finds the integer which is on …

Is this priority or parity! solution codechef Read More »

Path Parity solution codechef

Path Parity solution codechef You are given an integer NN. Let AA be an N×NN×N grid such that Ai,j=i+N⋅(j−1)Ai,j=i+N⋅(j−1) for 1≤i,j≤N1≤i,j≤N. For example, if N=4N=4 the grid looks like: Path Parity solution codechef You start at the top left corner of the grid, i.e, cell (1,1)(1,1). You would like to reach the bottom-right corner, cell (N,N)(N,N). To do so, whenever you are at cell (i,j)(i,j), you can move …

Path Parity solution codechef Read More »