Arnab Chakraborty has Published 4452 Articles

Meeting Rooms II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:30:42

816 Views

Suppose there is an array of meeting time intervals. There are two times start and end times [[s1, e1], [s2, e2], ...] and each pair satisfies the rule (si < ei), We have to find the minimum number of conference rooms required.So, if the input is like [[0, 30], [5, ... Read More

Flatten 2D Vector in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:28:57

414 Views

Suppose we have a 2D vector, we have to design and implement an iterator to flatten that 2d vector. There will be different methods as follows −next() − This will return the next element of the current elementhasNext() − This will check whether next element is present or notSo, if ... Read More

Count Univalue Subtrees in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:26:39

195 Views

Suppose we have a binary tree; we have to count the number of uni-value subtrees. Here the Uni-value subtree indicates all nodes of the subtree have the same value.So, if the input is like root = [5, 1, 5, 5, 5, null, 5], then the output will be 4To solve ... Read More

Group Shifted Strings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:23:44

114 Views

Suppose we have a string, we can "shift" each of its letter to its successive letter, so: "abc" can be changed to "bcd". We can keep doing this operation which forms the sequence: "abc" -> "bcd" -> ... -> "xyz". If we have a list of non-empty strings that contains ... Read More

Strobogrammatic Number II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:21:46

397 Views

Suppose we have a length n. We have to find all strobogrammatic numbers that are of length n.As we know that a strobogrammatic number is a number that looks the same when rotated 180 degrees.So, if the input is like n = 2, then the output will be ["11", "69", ... Read More

Shortest Word Distance III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:19:46

139 Views

Suppose we have a list of words and another two words called word1 and word2, we have to find the shortest distance between these two words in the list. Here word1 and word2 may be the same and they represent two individual words in the list. Let us assume that ... Read More

Shortest Word Distance II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:17:13

283 Views

Suppose there is a class that receives a list of words in the constructor, there will be a method that takes two words word1 and word2 and find the shortest distance between these two words in the list. That method will be called repeatedly many times with different parameters.Let us ... Read More

Reverse Words in a String II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:15:16

737 Views

Suppose we have one input string, we have to reverse the strings word by word.So, if the input is like ["t", "h", "e", " ", "m", "a", "n", " ", "i", "s", " ", "n", "l", "c", "e"], then the output will be ["n", "l", "c", "e", " ", "i", ... Read More

Missing Ranges in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:13:29

166 Views

Suppose we have a sorted integer array nums, the range of elements are in the inclusive range [lower, upper], we have to find the missing ranges.So, if the input is like nums = [0, 1, 3, 50, 75], and lower value is 0 and upper value is 99, then the ... Read More

One Edit Distance in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:10:40

112 Views

Suppose we have two strings s and t; we have to check whether they are both one edit distance apart. The one edit distance has three types −Insert a character into s to get tDelete a character from s to get tReplace a character of s to get tSo, if ... Read More

Advertisements