Arnab Chakraborty has Published 4293 Articles

Next Greater Element III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 13:09:59

257 Views

Suppose we have a positive 32-bit integer n, we need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If we have no such positive 32-bit integer number, then return -1.So if the number is ... Read More

Optimal Division in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 13:06:53

321 Views

Suppose we have a list of positive integers; the adjacent integers will perform the float division. So for example, [2, 3, 4] -> 2 / 3 / 4. Now, we can add any number of parenthesis at any position to change the priority of these operations. We should find out ... Read More

Minimum Time Difference in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 13:02:31

464 Views

Suppose we have a list of 24-hour clock time points in "Hour:Minutes" format, we have to find the minimum minutes difference between any two time points in the list. So if the input is like [“12:30”, ”15:17”], so this will return 167.To solve this, we will follow these steps −Define ... Read More

Complex Number Multiplication in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 12:58:28

2K+ Views

Suppose we have two strings that are representing complex numbers, we have to parse them and perform complex number multiplication, then return result as a string.So if the input is like “1+-1i” and “1+-1i”, then the result will be “0+-2i”.To solve this, we will follow these steps −aa := a ... Read More

Top K Frequent Elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 10:10:02

2K+ Views

Suppose we have a non-empty array of integer numbers. we have to return the kth most frequent elements. So if the elements are [1, 1, 1, 1, 2, 2, 3, 3, 3] and k = 2, then the result will beFormally the function should −Return true if there exists i, ... Read More

Increasing Triplet Subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 10:09:06

616 Views

Suppose there is an unsorted array. We have to check whether an increasing subsequence of length 3 exists or not in that array.Formally the function should −Return true if there exists i, j, ksuch that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 ... Read More

Odd Even Linked List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 10:07:50

719 Views

Suppose we have a singly linked list, we have to group all odd nodes together followed by the even nodes. Here we are talking about the node position not the value in the nodes. We should try to do it in place. So if the nodes are [1, 22, 13, ... Read More

Best Time to Buy and Sell Stock with Cooldown in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 10:00:51

167 Views

Suppose we have an array for which the ith element is the price of a given stock on the day i. We have to design an algorithm to find the maximum profit. We may complete as many transactions as we want (So, buy one and sell one share of the ... Read More

Longest Increasing Subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 09:10:18

3K+ Views

Suppose we have an unsorted list of integers. We have to find the longest increasing subsequence. So if the input is [10, 9, 2, 5, 3, 7, 101, 18], then the output will be 4, as the increasing subsequence is [2, 3, 7, 101]To solve this, we will follow these ... Read More

Find the Duplicate Number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-May-2020 09:09:06

3K+ Views

Suppose we have an array nums containing n + 1 integers. The members are in range 1 to n. prove that at least one duplicate number must be there. Assume that there is only one duplicate number, we have to find that duplicate element. So if the array is like ... Read More

Advertisements