Arnab Chakraborty has Published 4293 Articles

Minimum Number of Arrows to Burst Balloons in C++

Arnab Chakraborty

Arnab Chakraborty

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

305 Views

Suppose there are few spherical balloons spread in two-dimensional space. For each balloon, there are the start and end coordinates of the horizontal diameter. Start is always smaller than end. There will be at most 104 balloons. One arrow can be shot up exactly vertically from different points along the ... Read More

Delete Node in a BST in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 10:05:03

4K+ Views

Suppose we have a binary search tree. We will take one key k, and we have to delete the given key k from the BST, and return the updated BST. So if the tree is like −And the key k = 3, then the output tree will be −To solve ... Read More

Non-overlapping Intervals in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:58:31

594 Views

Suppose we have a collection of intervals; we have to find the minimum number of intervals we need to remove to make the rest of the intervals non-overlapping. So if the intervals are [[1, 2], [2, 3], [3, 4], [1, 3]], then the output will be 1, as we have ... Read More

N-ary Tree Level Order Traversal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:56:58

457 Views

Suppose we have an n-ary tree, we have to return the level order traversal of its nodes' values. The Nary-Tree input serialization is represented in their level order traversal. Here each group of children is separated by the null value (See examples). So the following tree can be represented as ... Read More

Delete Tree Nodes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:50:17

272 Views

Suppose we have a tree, this tree is rooted at node 0, this is given as follows −Number of nodes is nodesValue of ith node is value[i]Parent of ith node is parent[i]We have to remove every subtree whose sum of values of nodes is 0, after doing that return the ... Read More

Remove Interval in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:47:27

315 Views

Suppose we have a sorted list of disjoint intervals, each interval intervals[i] = [a, b] represents the set of numbers x such that a b[0], then swap a and bif a and b are intersecting, then call manipulate2(ans, t)return ansExample(C++)Let us see the following implementation to get a better ... Read More

Wiggle Sort II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:46:02

492 Views

Suppose we have an unsorted array nums, we have to rearrange it such that nums[0] < nums[1] > nums[2] < nums[3]. So if the input is like [1, 5, 1, 1, 6, 4], then the output will be [1, 4, 1, 5, 1, 6].To solve this, we will follow these ... Read More

Count Number of Nice Subarrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:43:00

856 Views

Suppose we have an array of integers nums and an integer k. A subarray is known as nice subarray if there are k odd numbers on it. We have to find the number of nice sub-arrays. So if the array is [1, 1, 2, 1, 1], and k = 3, ... Read More

Maximal Square in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:40:51

393 Views

Suppose we have a 2D binary matrix filled with 0's and 1's. We have to find the largest square containing only 1's and return its area. So if the matrix is like −10100101101111110010Then the output will be 4To solve this, we will follow these steps −ans := 0, n := ... Read More

Minimum Swaps to Make Strings Equal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 09:40:37

518 Views

Suppose we have two strings s1 and s2 of equal length consisting of letters only "x" and "y". Our task is to make these two strings equal to each other. We can swap any two characters that belong to different strings, which means − swap s1[i] and s2[j]. We have ... Read More

Advertisements