Arnab Chakraborty has Published 4293 Articles

Check for balanced parentheses in an expression - O(1) space - O(N^2) time complexity in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:38:45

442 Views

ConceptWith respect of given a string str containing characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, the task is to find if brackets are balanced or not.Brackets are denoted as balanced if −We close open brackets must be closed by the same type of brackets.Again we close open brackets according ... Read More

Flood fill algorithm using C graphics

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:34:42

5K+ Views

ConceptWith respect of a given rectangle, our task is to fill this rectangle applying flood fill algorithm.Input rectangle(left = 50, top = 50, right= 100, bottom = 100) floodFill( a = 55, b = 55, NewColor = 12, OldColor = 0)Output Method// A recursive function to replace previous color 'OldColor' at '(a, ... Read More

Find the Largest Cube formed by Deleting minimum Digits from a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:32:46

185 Views

ConceptWith respect of given number N, our task is to determine the largest perfect cube that can be formed by deleting minimum digits (possibly 0) from the number. So any digit can be deleted from the given number to reach the target.A is called a perfect cube if A = ... Read More

Find the largest Complete Subtree in a given Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:29:39

297 Views

ConceptWith respect of a given Binary Tree, the task is to determine the size of maximum complete sub-tree in the given Binary Tree.Complete Binary Tree – A Binary tree is treated as Complete Binary Tree if all levels are completely filled without possibly the last level and the last level ... Read More

Shortest Distance from All Buildings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:28:47

685 Views

Suppose we want to make a house on an empty land which reaches all buildings in the shortest amount of distance. We can only move four directions like up, down, left and right. We have a 2D grid of values 0, 1 or 2, where −0 represents an empty land ... Read More

Longest Increasing Path in a Matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:28:09

571 Views

Suppose we have one matrix; we have to find the length of the longest increasing path. From each cell, we can either move to four directions − left, right, up or down. We cannot move diagonally or move outside of the boundary.So, if the input is like994668211then the output will ... Read More

Find LCA in Binary Tree using RMQ in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:24:02

179 Views

ConceptThe article explains a method to solving the problem of finding the LCA of two nodes in a tree by reducing it to a RMQ problem.Examples Lowest Common Ancestor (LCA) of two nodes a and b in a rooted tree T is defined as the node located farthest from the root ... Read More

Find a pair from the given array with maximum nCr value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:17:14

196 Views

ConceptWith respect of given an array arr[] of n positive integers, the task is to determineelements arr[i] and arr[j] from the array such that arr[i]Carr[j] is at most possible. With respect of more than 1 valid pairs, print any one of them.Input arr[] = {4, 1, 2}Output 4 2 4C1 = 4 ... Read More

Minimum removals from array to make GCD Greater in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:09:21

291 Views

ConceptWith respect of given N numbers, the target is to determine the minimum removal of numbers such that GCD of the remaining numbers is larger than initial GCD of N numbers. If it is impossible to increase the GCD, print “NO”.Input b[] = {1, 2, 4}Output1After removing the first element, then ... Read More

Minimum edges required to add to make Euler Circuit in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 06:48:55

269 Views

ConceptWith respect of a given undirected graph of b nodes and a edges, the job is to determine minimum edges needed to build Euler Circuit in the given graph.Input b = 3, a = 2 Edges[] = {{1, 2}, {2, 3}}Output 1By connecting 1 to 3, we can build a Euler Circuit.MethodWith ... Read More

Advertisements