Arnab Chakraborty has Published 4293 Articles

Median of Two Sorted Arrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 11:17:49

454 Views

Suppose we have two arrays; these arrays are sorted. So we have to find the median of these two arrays. So if the arrays are like [1, 5, 8] and [2, 3, 6, 9], then the answer will be 5.To solve this, we will follow these steps −Define a function ... Read More

Relative Sort Array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-May-2020 05:54:15

756 Views

Suppose we have two arrays arr1 and arr2, the elements of arr2 are unique, and all elements in arr2 are also present in arr1. We have to sort the elements of arr1 in such a way that the relative ordering of items in arr1 are the same as in arr2. ... Read More

Mirror Reflection in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:32:51

795 Views

Suppose there is a special square room with mirrors on each of the four walls. In each corner except the southwest corner, there are receptors. These are numbered as 0, 1, and 2. Now the square room has walls of length p, and a laser ray from the southwest corner ... Read More

Score of Parentheses in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:30:48

383 Views

Suppose we have a balanced parentheses string S, we have to compute the score of the string based on the following rule −The () has score 1AB has score A + B, where A and B are two balanced parentheses strings.(A) has score 2 * A, where A is a ... Read More

Car Fleet in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:28:29

536 Views

Suppose there are N cars that are going to the same destination along a one lane road. The destination is ‘target’ miles away. Now each car i has a constant speed value speed[i] (in miles per hour), and initial position is position[i] miles towards the target along the road.A car ... Read More

Shifting Letters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:27:18

3K+ Views

Suppose we have a string S of lowercase letters, and an integer array shifts. The shift of a letter means the next letter in the alphabet, for z, it will be a. Now for each shifts[i] = x, we want to shift the first i+1 letters of S, x times. ... Read More

Hand of Straights in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:24:24

573 Views

Suppose Rima has a hand of cards, given as an array of integers. Now she wants to shuffle the cards into groups so that each group is size W, and consists of W consecutive cards. We have to check whether it is possible or not.So if the cards are [1, ... Read More

Longest Mountain in Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:22:05

543 Views

Consider any (contiguous) subarray B (of A) a called mountain if the following properties hold −size of B >= 3There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]Suppose we have an ... Read More

New 21 Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:19:03

384 Views

Suppose Rima plays the following game, that is loosely based on the card game "21". So Rima starts with 0 points, and draws numbers while she has less than K points. Now, during each draw, she gains an integer number of points randomly from the range [1, W], where W ... Read More

Find And Replace in String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-May-2020 10:15:24

2K+ Views

Suppose we have a string S, we will perform some replacement operations that replace groups of letters with new ones. In each replacement operation there are 3 parameters − a starting index i, a source word x and a target word y. Now the rule is that if x starts ... Read More

Advertisements