Coding

Coding

[Solution] Pyramid Traversal solution codechef

Pyramid Traversal solution codechef You are given a pyramid of the following form with an infinite number of rows: 11 2 32 3 4 5 64 5 6 7 8 9 107 8 9 10 ………..……….. From a cell, you can move to either the bottom-left cell or the bottom-right cell directly in contact with the current one (For example, you can make the following moves: 1→2,1→3,6→9,6→101→2,1→3,6→9,6→10, while …

[Solution] Pyramid Traversal solution codechef Read More »

[Solution] Rock Paper Scissors solution codechef

Rock Paper Scissors solution codechef There are NN players standing in a line, indexed 11 to NN from left to right. They all play a game of Rock, Paper, Scissors. Each player has already decided which move they want to play. You are given this information as a string SS of length NN, i.e, SiSi is equal to 𝚁R if player ii will play Rock. SiSi is equal to 𝙿P if player ii will …

[Solution] Rock Paper Scissors solution codechef Read More »

[Solution] Increasing String solution codechef

Increasing String solution codechef You are given a string SS, consisting of lowercase English letters. You can do the following operation at most once : Choose a subsequence of the string SS, then remove it from SS and concatenate the subsequence at the end of the remaining string. Find the lexicographically minimum string that can be obtained by performing this operation at most once on SS. …

[Solution] Increasing String solution codechef Read More »

[Solution] Squares Counting solution codechef

Squares Counting solution codechef You are given a binary square matrix AA of size N×NN×N. Let the value at cell (i,j)(i,j) be denoted by A(i,j)A(i,j). Your task is to count the number of square frames present in the grid. A square frame is defined to be a square submatrix of AA whose border elements are all ‘1’. Formally, A square submatrix of AA of size kk with top-left corner (i,j)(i,j) is defined to …

[Solution] Squares Counting solution codechef Read More »

[Solution] Check Mate solution codechef

Check Mate solution codechef You are given a standard 8×88×8 chessboard which has exactly 33 pieces placed on it – 22 black rooks and 11 white king. The rows are numbered 11 to 88 from bottom to top, and the columns are numbered 11 to 88 from left to right. The cell at the intersection of the ii-th column and jj-th row is denoted (i,j)(i,j) (like the coordinate system on the xyxy-plane). Is it possible for …

[Solution] Check Mate solution codechef Read More »