Arnab Chakraborty has Published 4452 Articles

Longest Substring with At Most Two Distinct Characters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:09:04

1K+ Views

Suppose we have a string s; we have to find the length of the longest substring t that has at most 2 distinct characters.So, if the input is like "eceba", then the output will be 3 as t is "ece" which its length is 3.To solve this, we will follow ... Read More

Binary Tree Upside Down in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 11:07:24

257 Views

Suppose we have a binary tree where all the right nodes are either leaf nodes with a sibling otherwise empty, we have to flip it upside down and turn it into a tree where the original right nodes turned into left leaf nodes. We have to return the new node.So, ... Read More

Synonymous Sentences in C++

Arnab Chakraborty

Arnab Chakraborty

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

337 Views

Suppose we have a list of pairs of equivalent words synonyms and a sentence text, we have to find all possible synonymous sentences they are sorted lexicographically.So, if the input is like synonyms = [["happy", "joy"], ["sad", "sorrow"], ["joy", "cheerful"]], and text = "I am happy today but was sad ... Read More

Campus Bikes II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:59:02

181 Views

Suppose we have a 2D grid, that represents a campus, there are N workers and M bikes, The value of N

The k Strongest Values in an Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:56:36

152 Views

Suppose we have an array of numbers called arr and an integer k. There is a value arr[i] that is said to be stronger than a value arr[j] when |arr[i] - m| > |arr[j] - m| where m is the median of the array. If |arr[i] - m| is same ... Read More

Reorder Routes to Make All Paths Lead to the City Zero in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:54:10

361 Views

Suppose there are n different cities those are numbered from 0 to n-1 and there are also n-1 roads such that there is only one way to travel between two different cities. Suppose the ministry of transport decided to orient the roads in one direction because they are too narrow.Here ... Read More

Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:51:57

129 Views

Suppose we have a rectangular cake with height h and width w, we also have two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] represents the distance from the top of the rectangular cake to the ith horizontal cut and similarly, verticalCuts[j] represents distance from the left of the rectangular ... Read More

Course Schedule IV in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:49:16

235 Views

Suppose there are a total of n courses we can to take, the courses are labeled from 0 to n-1.Some courses may have direct prerequisites, as example, to take course 0 we have first to take course 1, which is expressed as a pair: [1, 0].So, if we have a ... Read More

Check If a String Contains All Binary Codes of Size K in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:46:40

180 Views

Suppose we have a binary string s and an integer k. We have to check whether every binary code of length k is a substring of s. Otherwise, return False.So, if the input is like S = "00110110", k = 2, then the output will be true. The binary codes ... Read More

Pseudo-Palindromic Paths in a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Nov-2020 10:44:28

236 Views

Suppose we have a binary tree where node values are digits from 1 to 9. One path in the binary tree is said to be pseudo-palindromic when at least one permutation of the node values in the path is a palindrome. We have to find the number of pseudo-palindromic paths ... Read More

Advertisements