Arnab Chakraborty has Published 4293 Articles

Degree of an Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:43:10

628 Views

Suppose we have an array of non-negative integers called nums, the degree of this array is actually the maximum frequency of any one of its elements. We have to find the smallest possible length of a contiguous subarray of nums, that has the same degree as nums.So, if the input ... Read More

Count Binary Substrings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:41:25

797 Views

Suppose we have a string s, we have to find the count of contiguous substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. If substrings occur multiple times are counted the number of times they ... Read More

Binary Number with Alternating Bits in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:39:16

461 Views

Suppose we have a positive integer, we have to check whether it has alternating bits − so, two adjacent bits will always have different values.So, if the input is like 10, then the output will be True, as binary representation of 10 is 1010.To solve this, we will follow these ... Read More

Employee Importance in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:38:36

268 Views

Suppose we have a data structure of employee information, there are employee's unique id, his importance value and his direct subordinates' id. As an example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. And suppose their importance values are 15, 10 ... Read More

Baseball Game in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:36:37

2K+ Views

Suppose we have a baseball game point recorder. We have a list of strings; each string can be one of the 4 following types −Integer (one round's score) − Indicates the number of points we get in this round."+" (one round's score) − Indicates the points we get in this ... Read More

Longest Continuous Increasing Subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:34:52

845 Views

Suppose we have an array of integers; we have to find the length of longest continuous increasing subarray.So, if the input is like [2, 4, 6, 5, 8], then the output will be 3. As the longest continuous increasing subsequence is [2, 4, 6], and its length is 3.To solve ... Read More

Second Minimum Node In a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:33:20

602 Views

Suppose there is a non-empty special binary tree with some non-negative value, here each node in this tree has exactly two or zero children. If the node has two children, then this node's value is the smaller value among its two children. In other words, we can say that [root.val ... Read More

Construct String from Binary Tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jul-2020 09:28:32

868 Views

Suppose we have a binary tree we have to make a string consists of parenthesis and integers from a binary tree with the preorder traversing way. A null node will be represented by empty parenthesis pair "()". And we need to omit all the empty parenthesis pairs that don't affect ... Read More

Prim’s (Minimum Spanning Tree) MST Algorithm

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jul-2020 13:02:11

1K+ Views

There is a connected graph G(V, E) and the weight or cost for every edge is given. Prim’s Algorithm will find the minimum spanning tree from the graph G.It is growing tree approach. This algorithm needs a seed value to start the tree. The seed vertex is grown to form ... Read More

Single-Source Shortest Paths, Nonnegative Weights

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jul-2020 13:00:42

870 Views

The single source shortest path algorithm (for non-negative weight) is also known Dijkstra algorithm. There is a given graph G(V, E) with its adjacency matrix representation, and a source vertex is also provided. Dijkstra’s algorithm to find the minimum shortest path between source vertex to any other vertex of the ... Read More

Advertisements