Arnab Chakraborty has Published 4293 Articles

Counting Maximal Value Roots in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:12:17

167 Views

Suppose we have a binary tree root; we have to count the number of nodes where its value is greater than or equal to the values of all of its descendants.So, if the input is likethen the output will be 4 as all nodes except 3, it meets the criteria.To ... Read More

Compress String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:09:05

3K+ Views

Suppose we have a string s, we have to eliminate consecutive duplicate characters from the given string and return it. So, if a list contains consecutive repeated characters, they should be replaced with a single copy of the character. The order of the elements will be same as before.So, if ... Read More

Cha Cha Slide C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:07:11

205 Views

Suppose we have two strings s and t. we have to check whether s is rotation of t or not, in other words, can we get t after rotating s?So, if the input is like s = "helloworld" and t = "worldhello", then the output will be True.To solve this, ... Read More

Minimum String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:05:42

1K+ Views

Suppose we have two strings s and t of same length, and both are in lowercase letters. Consider we have rearranged s at first into any order, then count the minimum number of changes needed to turn s into t.So, if the input is like s = "eccynue", t = ... Read More

TV Shows in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:04:01

518 Views

Suppose we have a list of TV shows, and another list of duration, and an integer k, here shows[i] and duration[i] shows the name and duration watched by the ith person, we have to find the total duration watched of the k most watched shows.So, if the input is like ... Read More

Unique Fractions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 12:01:58

278 Views

Suppose we have a list of fractions where each fraction contains [numerator, denominator] (numerator / denominator). We have ti find a new list of fractions such that the numbers in fractions are −In their most reduced terms. (20 / 14 becomes 10 / 7).Any duplicate fractions (after reducing) will be ... Read More

Revolving Door in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 11:59:33

318 Views

Suppose we have a list of requests, where requests[i] contains [t, d] indicating at time t, a person arrived at the door and either wanted to go inside (inside is indicating using 1) or go outside (outside is indicating using 0).So if there is only one door and it takes ... Read More

Most Frequent Number in Intervals in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 11:53:14

536 Views

Suppose we have a list of lists of integers intervals where each element has interval like [start, end]. We have to find the most frequently occurred number in the intervals. If there are ties, then return the smallest number.So, if the input is like [[2, 5], [4, 6], [7, 10], ... Read More

Beer Bottles in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 11:47:59

286 Views

Suppose we have one number n. Here n indicates n full beer bottles. If we can exchange 3 empty beer bottles for 1 full beer bottle, we have to find the number of beer bottles we can drink.So, if the input is like 10, then the output will be 14.To ... Read More

Large to Small Sort in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Sep-2020 11:46:32

756 Views

Suppose we have a list of integers nums, we have to sort the list in this manner −First element is maximumSecond element is minimumThird element is 2nd maximumFourth element is 2nd minimumAnd so on.So, if the input is like [6, 3, 10, 4], then the output will be [10, 3, ... Read More

Advertisements