Arnab Chakraborty has Published 4293 Articles

Longest ZigZag Path in a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 13:18:28

914 Views

Suppose we have a binary tree root, a ZigZag path for a binary tree is defined as follow −Choose any node in the binary tree and a direction (either right or left).If the current direction is right then moving towards the right child of the current node otherwise move towards ... Read More

Find the Longest Substring Containing Vowels in Even Counts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 13:12:13

365 Views

Suppose we have the string s, we have to find the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times. So if the string is like “helloworld”, then the output will ... Read More

Linked List in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 13:09:13

3K+ Views

Suppose we have a binary tree root and a linked list with a head as the first node. We have to return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise False. So if the ... Read More

Find All Anagrams in a String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 13:07:56

2K+ Views

Suppose we have a string s and a non-empty string p, we have to find all the start indices of p's anagrams in s. The strings consist of lowercase letters only and the length of both strings s and p will not be larger than 20 and 100. So for ... Read More

Closest Divisors in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 13:00:56

408 Views

Suppose we have an integer num, we have to find the closest two integers in absolute difference whose product equals num + 1 or num + 2. We have to find the two integers in any order. So if the input is 8, then the output will be [3, 3], ... Read More

Validate Binary Tree Nodes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 12:57:12

388 Views

Suppose we have n binary tree nodes numbered from 0 to n - 1 where node I has two children leftChild[i] and rightChild[i], we have to say true if and only if all the given nodes form exactly one valid binary tree. When node i has no left child then ... Read More

Number of Substrings Containing All Three Characters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 12:53:21

685 Views

Suppose we have given a string s consisting only of characters a, b and c. We have to return the number of substrings containing at least one occurrence of all these characters a, b and c. So for example, if the string is “abcabc”, then the output will be 10, ... Read More

Apply Discount Every n Orders in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 12:49:55

332 Views

Suppose there is a sale in a supermarket, there will be a discount every n customer. Consider there are some products in the supermarket where the id of the i-th product is products[i] and the price per unit of this product is prices[i]. Here the system will count the number ... Read More

Maximum Number of Events That Can Be Attended in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 12:45:51

850 Views

Suppose we have an array of events where events[i] = [startDayi, endDayi]. Here every event I start at startDayi and ends at endDayi. We can attend an event I at any day d where d in range startTimei and endTimei (both inclusive). We have to keep in mind that we ... Read More

Product of the Last K Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 12:42:02

352 Views

Suppose we have the implement the class called ProductOfNumbers that supports two methods −add(int num): This adds the number num to the back of the current list of numbers.getProduct(int k): This returns the product of the last k numbers in the current list.We can assume that always the current list ... Read More

Advertisements