Arnab Chakraborty has Published 4293 Articles

Valid Parenthesis String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 07:02:40

1K+ Views

Suppose we have an expression. The expression has some parentheses; we have to check the parentheses are balanced or not. The order of the parentheses are (), {} and []. Suppose there are two strings. “()[(){()}]” this is valid, but “{[}]” is invalid.To solve this, we will follow these steps ... Read More

Counting Bits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:59:03

2K+ Views

Suppose we have a non-negative integer number num. For each number i in the range 0 ≤ i ≤ num we have to calculate the number of 1's in their binary counterpart and return them as a list. So if the number is 5, then the numbers are [0, 1, ... Read More

Largest Number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:55:35

584 Views

Suppose there is a list of non-negative integers, we have to arrange them such that they form the largest number. So if the array is [10, 2], then the largest number will be 210.To solve this, we will follow these steps −Arrange the numbers where the most significant digits are ... Read More

Evaluate Reverse Polish Notation in C++ Program

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:44:43

5K+ Views

Suppose we have Reverse polish notation and we have to evaluate the value. The reverse polish notation is also known as postfix expression. Here we have to use the stack data structure to solve the postfix expressions.From the postfix expression, when some operands are found, pushed them in the stack. ... Read More

Word Break in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:39:14

972 Views

Suppose we have one non-empty string s and a dictionary wordDict. That is containing a list of non-empty words, determine when s can be segmented into a space-separated sequence of one or more dictionary words. We have to follow some rules −The same word in the dictionary may be reused ... Read More

Gas Station in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:33:33

619 Views

Suppose there is a circle, and there are n gas stations on the circle. We have two sets of data like −The amount of gas that every gas stations hasDistance from one gas stations to another.Calculate the first point, from where a car will be able to complete the circle. ... Read More

Palindrome Partitioning in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:28:15

440 Views

Suppose we have one input string, a partitioning of that string is palindrome partitioning, when every substring of the partition is a palindrome. In this section, we have to find the minimum cuts are needed to palindrome partitioning the given string. So if the string is like “ababbbabbababa” Minimum cut ... Read More

Binary Tree Level Order Traversal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:19:26

3K+ Views

Suppose we have a binary tree. We have to traverse this tree using the level order traversal scheme. So if the tree is likeThe traversal sequence will be like − [10, 5, 16, 8, 15, 20, 23]To solve this, we will follow these steps −define queue que to store nodesinsert ... Read More

Binary Tree Inorder Traversal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:11:48

3K+ Views

Suppose we have a binary tree. We have to traverse this tree using the inorder traversal scheme without using recursion. So if the tree is likeThen the traversal will be [2, 5, 7, 10, 15, 20]To solve this, we will follow these steps −Create two array res and stack, set ... Read More

Decode Ways in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 06:06:16

1K+ Views

Suppose we have a message containing letters from A to Z is being encoded to numbers using the following mapping − 'A' → 1, 'B' → 2 ... 'Z' → 26. So if we have one non-empty string, containing only digits, then we have to find, in how many ways ... Read More

Advertisements