Arnab Chakraborty has Published 4293 Articles

Factor Combinations in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:33:01

288 Views

Suppose we have a number. The numbers can be regarded as a product of its factors. So, 8 = 2 x 2 x 2; = 2 x 4. We have to make one function that takes an integer n and return all possible combinations of its factors.So, if the input ... Read More

Meeting Rooms II in C++

Arnab Chakraborty

Arnab Chakraborty

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

1K+ 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

726 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

275 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

198 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

477 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

225 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

375 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

Missing Ranges in C++

Arnab Chakraborty

Arnab Chakraborty

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

239 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

185 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