Arnab Chakraborty has Published 4293 Articles

Longest Turbulent Subarray in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:54:39

416 Views

Consider a subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent when it meets these conditions −For i A[k+1] when k is odd, and A[k] < A[k+1] when k is even;Otherwise, for i A[k+1] when k is even, and A[k] < A[k+1] when k is ... Read More

Numbers With Same Consecutive Differences in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:44:37

299 Views

Suppose we have to find all non-negative integers of length N such that the absolute difference between every two consecutive digits is K. We have to keep in mind that every number in the answer must not have leading zeros except for the number 0 itself. We may return the ... Read More

Maximum Width Ramp in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:41:11

411 Views

Suppose we have an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i]

Prison Cells After N Days in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:33:33

467 Views

Suppose there are 8 prison cells in a row, and in each cell there is a prisoner or that is empty. In each day, whether the cell is occupied or vacant changes according to the following rules −If one cell has two adjacent neighbors that are both occupied or both ... Read More

Array of Doubled Pairs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:29:46

301 Views

Suppose we have an array of integers A with even length, now we have to say true if and only if it is possible to reorder it in such a way that A[2 * i + 1] = 2 * A[2 * i] for every 0 0, thenif m[key ... Read More

Reveal Cards In Increasing Order in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:25:09

448 Views

Suppose we have a deck of cards; every card has a one unique number. We can order the deck in any order that we want. So Initially, all the cards start face down (unrevealed) in one deck. Now, we do the following steps multiple times, until all cards are revealed ... Read More

Bag of Tokens in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:11:23

420 Views

Suppose we have an initial power P, an initial score of 0 points, and one bag of tokens. Now each token can be used at most once, there is a value token[i], and has potentially two ways to use it, these are as follows −If we have at least token[i] ... Read More

Remove Sub-Folders from the Filesystem in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:10:36

278 Views

Suppose we have a list of folders, we have to remove all sub-folders in those folders and return in any order the folders after removing. Here if a folder[i] is located within another folder[j], it is denoted as subfolder of it. The paths will be like folder1/subfolder2/… etc.Suppose the input ... Read More

Minimum Increment to Make Array Unique in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:08:33

361 Views

Suppose we have an array of integers A, here a move consists of choosing any A[i], and incrementing it by 1. We have to find the least number of moves to make every value in A unique. So if the input is like [3, 2, 1, 2, 1, 7], then ... Read More

Toss Strange Coins in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:05:59

669 Views

Suppose we have some coins. The i-th coin has a probability prob[i] of facing heads when tossed. We have to show the probability that the number of coins facing heads equals target if you toss every coin exactly once. So if the prob array is like [0.5, 0.5, 0.5, 0.5, ... Read More

Advertisements