Arnab Chakraborty has Published 4452 Articles

Android Unlock Patterns in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:21:48

873 Views

Suppose we have an Android 3x3 key lock screen and two integers m and n, the values of m and n are in range 1 ≤ m ≤ n ≤ 9, We have to count the total number of unlock patterns of the Android lock screen, which consist of minimum ... Read More

Largest BST Subtree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:19:14

86 Views

Suppose we have a binary tree; we have to find the largest subtree of it where largest means subtree with largest number of nodes in it.So, if the input is like, then the output will be 3, as the Largest BST Subtree, in this case, is the highlighted one.To solve ... Read More

Maximum Size Subarray Sum Equals k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:15:47

719 Views

Suppose we have an array called nums and a target value k, we have to find the maximum length of a subarray that sums to k. If there is not present any, return 0 instead.So, if the input is like nums = [1, -1, 5, -2, 3], k = 3, ... Read More

Number of Connected Components in an Undirected Graph in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:13:59

2K+ Views

Suppose we have n nodes and they are labeled from 0 to n - 1 and a list of undirected edges, are also given, we have to define one function to find the number of connected components in an undirected graph.So, if the input is like n = 5 and ... Read More

Generalized Abbreviation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:11:31

176 Views

Suppose there is a word. We have to define a function that can generate the generalized abbreviations of a word.So, if the input is like "word", then the output will be ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]To solve this, we ... Read More

Binary Tree Vertical Order Traversal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:08:23

271 Views

Suppose there is a binary tree, we have to find the vertical order traversal of its nodes' values. If two nodes are in the same row and column, the order should be from left to right.So, if the input is like, then the output will be [[9], [3, 15], [20], ... Read More

Sparse Matrix Multiplication in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:03:42

2K+ Views

Suppose we have two matrices A and B, we have to find the result of AB. We may assume that A's column number is equal to B's row number.So, if the input is like [[1, 0, 0], [-1, 0, 3]] [[7, 0, 0], [0, 0, 0], [0, 0, 1]], 100-103700000001then ... Read More

Binary Tree Longest Consecutive Sequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 12:01:24

127 Views

Suppose we have a binary tree; we have to check whether we can find the length of the longest consecutive sequence path. If the path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need ... Read More

Flip Game II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:58:34

221 Views

Suppose there are two players who are playing the flip game. Here we have a string that contains only these two characters: + and -, player1 and player2 take turns to flip two consecutive "++" into "--". The game ends when one player can no longer make a move and ... Read More

Walls and Gates in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:56:50

409 Views

Suppose we have one m x n 2D grid, and that is initialized with these three possible values.-1 for a wall or an obstacle.0 for a gate.INF This is infinity means an empty room.Here 2^31 - 1 = 2147483647 is INF as we may assume that the distance to a ... Read More

Advertisements