Arnab Chakraborty has Published 3734 Articles

The k Strongest Values in an Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:56:36

256 Views

Suppose we have an array of numbers called arr and an integer k. There is a value arr[i] that is said to be stronger than a value arr[j] when |arr[i] - m| > |arr[j] - m| where m is the median of the array. If |arr[i] - m| is same ... Read More

Reorder Routes to Make All Paths Lead to the City Zero in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:54:10

550 Views

Suppose there are n different cities those are numbered from 0 to n-1 and there are also n-1 roads such that there is only one way to travel between two different cities. Suppose the ministry of transport decided to orient the roads in one direction because they are too narrow.Here ... Read More

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:51:57

253 Views

Suppose we have a rectangular cake with height h and width w, we also have two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] represents the distance from the top of the rectangular cake to the ith horizontal cut and similarly, verticalCuts[j] represents distance from the left of the rectangular ... Read More

Course Schedule IV in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:49:16

340 Views

Suppose there are a total of n courses we can to take, the courses are labeled from 0 to n-1.Some courses may have direct prerequisites, as example, to take course 0 we have first to take course 1, which is expressed as a pair: [1, 0].So, if we have a ... Read More

Pseudo-Palindromic Paths in a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:44:28

373 Views

Suppose we have a binary tree where node values are digits from 1 to 9. One path in the binary tree is said to be pseudo-palindromic when at least one permutation of the node values in the path is a palindrome. We have to find the number of pseudo-palindromic paths ... Read More

Maximum Number of Vowels in a Substring of Given Length in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:35:02

631 Views

Suppose we have a string s and an integer k. We have to find the maximum number of vowel letters in any substring of s with length k.So, if the input is like s = "abciiidef", k = 3, then the output will be 3To solve this, we will follow ... Read More

People Whose List of Favorite Companies Is Not a Subset of Another List in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:33:21

175 Views

Suppose we have an array called favorite companies where favoriteCompanies[i] is the list of favorites companies of the ith person. We have to find the indices of people whose list of favorite companies is not a subset of any other list of favorites companies.So, if the input is like favoriteCompanies ... Read More

Rearrange Words in a Sentence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:30:43

902 Views

Suppose we have a string with different words, that string is called sentence, and this is in the following format −First letter is in upper case.Each word in text are separated by a single space character.We have to rearrange the words in text such that all words are rearranged in ... Read More

Count Good Nodes in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:27:48

500 Views

Suppose we have a binary tree, a node X in the tree is named good when in the path from root to X there are no nodes whose value is greater than X. Here we have to find the number of good nodes in the binary tree.So, if the input ... Read More

Simplified Fractions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:24:59

438 Views

Suppose we have an integer n, we have to find a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator

Advertisements