Arnab Chakraborty has Published 4293 Articles

Possible Bipartition in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:54:50

219 Views

Suppose we have a set of N people (they are numbered 1, 2, ..., N), we would like to split everyone into two subgroups of any size. Now each person may dislike some other people, and they should not go into the same group. So, if dislikes[i] = [a, b], ... Read More

Remove Covered Intervals in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:51:38

308 Views

Suppose we have a list of intervals, we have to remove all intervals that are covered by another interval in the list. Here Interval [a,b) is covered by interval [c,d) if and only if c

Broken Calculator in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:51:35

360 Views

Suppose we have a broken calculator that has a number showing on its display, we can perform only two operations −Double − This will multiply the number on the display by 2, or;Decrement − This will decrease the number that is showing, by 1, Initially, the calculator is displaying the ... Read More

Spiral Matrix III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:50:56

416 Views

Suppose we have a 2 dimensional grid with R rows and C columns, we start from (r0, c0) facing east. Here, the north-west corner of the grid is at the first row and column, and the south-east corner of the grid is at the last row and column. We will ... Read More

Complete Binary Tree Inserter in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:50:52

1K+ Views

As we know a complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. We have to write a data structure CBTInserter that is initialized with a complete binary tree and it supports ... Read More

Iterator for Combination in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:49:00

551 Views

Suppose we have to design an Iterator class, that consists of few operations −Define a constructor that takes a string characters of sorted distinct lowercase English letters and a number combinationLength as parameter.Define a function next() that returns the next combination of length combinationLength in alphabetic order.Define another function hasNext() ... Read More

Boats to Save People in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:45:23

702 Views

Suppose we have an array called people. Now the i-th person has weight people[i], and each boat can carry a maximum weight of limit. If each boat carries at most 2 people at the same time, provided the sum of the weight of those people is at most limit. We ... Read More

Stone Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:41:58

573 Views

Suppose we have two players Alex and Lee they play a game with piles of stones. There are an even number of piles that are arranged in a row, and each pile has some number of stones piles[i]. The objective of the game is to end with the most stones. ... Read More

Koko Eating Bananas in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:36:31

442 Views

Suppose we have N piles of bananas, the i-th pile has piles[i] bananas. Here the guards have gone and will come back in H hours. Koko can decide her bananas-per-hour eating speed is K. Each hour, she takes some pile of bananas, and eats K bananas from that pile. If ... Read More

Sum of Subarray Minimums in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:35:55

266 Views

Suppose we have an array of integers A. We have to find the sum of min(B), where B ranges over every (contiguous) subarray of A. Since the answer may be very large, then return the answer in modulo 10^9 + 7. So if the input is like [3, 1, 2, ... Read More

Advertisements