Arnab Chakraborty has Published 4452 Articles

Sequence Reconstruction in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:56:33

149 Views

Suppose we have to check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. The original sequence is a permutation of the integers from 1 to n, and n in range 1 ≤ n ≤ 10^4. Here the reconstruction means making a shortest common supersequence ... Read More

Design Phone Directory in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:52:43

480 Views

Suppose we want to design a Phone Directory which supports the following operations −get − This will provide a number that is not assigned to anyone.check − This will check whether a number is available or not.release − This will recycle or release a number.Using the initializer, we can initialize ... Read More

Range Addition in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:50:25

140 Views

Suppose we have an array of size n and that is initialized with 0's and we also have a value k, we will perform k update operations. Each operation will be represented as triplet: [startIndex, endIndex, inc] which increments each element of subarray A[startIndex ... endIndex] (startIndex and endIndex inclusive) ... Read More

Plus One Linked List in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:48:16

144 Views

Suppose we have a non-negative integer represented as non-empty a singly linked list of digits, now we have to plus one to the integer. We may assume the integer do not contain any leading zero, except the number 0 itself. In the linked list the most significant digit is at ... Read More

Find Leaves of Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:45:51

496 Views

Suppose we have a binary tree. We will collect and remove all leaves and repeat until the tree is empty.So, if the input is likethen the output will be [[4, 5, 3], [2], [1]]To solve this, we will follow these steps −Define one map szDefine one 2D array retDefine a ... Read More

Nested List Weight Sum II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:43:00

222 Views

Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Different from the previous question where weight is increasing from root to ... Read More

Design Hit Counter in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:39:49

510 Views

Suppose we want to design a hit counter which counts the number of hits received in the past 5 minutes. There will be a function and that accepts a timestamp parameter in the second unit and we may assume that calls are being made to the system in chronological order ... Read More

Bomb Enemy in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:38:01

193 Views

Suppose we have a 2D grid, here each cell is either a wall 'W', an enemy 'E' or that is empty '0', We have to find the maximum enemies we can kill using one bomb. The bomb kills all the enemies in the same row and column from the planted ... Read More

Sort Transformed Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:35:05

179 Views

Suppose we have a sorted array of integer nums and integer values a, b and c. We have to apply a quadratic function of the form f(x) = ax^2 + bx + c to each element x in the array. And the final array must be in sorted order.So, if ... Read More

Line Reflection in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 09:32:53

381 Views

Suppose we have n points on a 2D plane, we have to check whether there is any line parallel to y-axis that reflect the given points symmetrically, in other words, check whether there exists a line that after reflecting all points over the given line the set of the original ... Read More

Advertisements