Arnab Chakraborty has Published 4293 Articles

Meeting Scheduler in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:03:11

1K+ Views

Suppose we have the availability time slots lists slots1 and slots2 of two people and a meeting duration d, we have to find the earliest time slot that works for both of them and is of duration d. If there is no common time slot that satisfies the requirements, then ... Read More

Binary Subarrays With Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 13:01:18

531 Views

Suppose an array A of 0s and 1s is given, we have to find how many non-empty subarrays have sum S? So if the input is like [1, 0, 1, 0, 1], and S = 2, then the result will be 4, as the subarrays are [1, 0, 1, 0, ... Read More

Dice Roll Simulation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:58:42

673 Views

Suppose a die simulator generates a random number from 1 to 6 for each roll. We want to introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Consider we have an array of integers rollMax and an integer n, ... Read More

Flip String to Monotone Increasing in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:55:51

362 Views

Suppose a string of '0's and '1's is given. That string will be monotonic increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0.). We have a string S of '0's and '1's, and we may flip any '0' to ... Read More

Path with Maximum Gold in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:55:21

529 Views

Suppose in a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 means that is empty. We have to find the maximum amount of gold that you can collect under the conditions −Every time ... Read More

Partition Array into Disjoint Intervals in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:52:20

442 Views

Suppose we have an array A, we have to partition it into two subarrays left and right such that −Every element in left subarray is less than or equal to every element in right subarray.left and right subarrays are non-empty.left subarray has the smallest possible size.We have to find the ... Read More

Stepping Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:50:13

359 Views

Suppose we have two integers low and high, we have to find and show a sorted list of all the Stepping Numbers in the range [low, high] inclusive. A Stepping Number is an integer means all of its adjacent digits have an absolute difference of exactly 1. For example, 321 ... Read More

Sort an Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:48:57

290 Views

Suppose we have an array of integers; we have to sort them in ascending order. So if the array is like [5, 2, 3, 1], then the result will be [1, 2, 3, 5]To solve this, we will follow these steps −Make one method called partition, this will take array, ... Read More

Remove All Adjacent Duplicates in String II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:47:11

697 Views

Suppose a string s is given, a k duplicate removal consists of choosing k adjacent and equal letters from string s and removing them causing the left and the right side of the deleted substring to concatenate together. We will repeatedly make k duplicate removals on the given string s ... Read More

Online Election in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 12:44:30

605 Views

Suppose in an election, the i-th vote was cast for persons[i] at time times[i]. Now, we have to implement the following query function: TopVotedCandidate.q(int t) this will find the number of the person that was leading the election at time t. Votes cast at time t will count towards our ... Read More

Advertisements