Arnab Chakraborty has Published 4293 Articles

Insert into a Binary Search Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 08:08:57

8K+ Views

Suppose we have a binary search tree. we have to write only one method, that performs the insertion operation with a node given as a parameter. We have to keep in mind that after the operation, the tree will remain BST also. So if the tree is like −if we ... Read More

Check If It Is a Straight Line in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 08:07:21

581 Views

Suppose we have a list of data-points consisting of (x, y) coordinates, we have to check whether the data-points are forming straight line or not. So if the points are like [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7)], then they are forming straight line.To solve ... Read More

Split a String in Balanced Strings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 08:05:26

493 Views

As we know that the balanced strings are those which have equal quantity of left and right characters. Suppose we have a balanced string s split it in the maximum amount of balanced strings. We have to return the maximum amount of splitted balanced strings. So if the string is ... Read More

Partition to K Equal Sum Subsets in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:59:22

439 Views

Suppose we have an array of integers called nums and a positive integer k, check whether it's possible to divide this array into k non-empty subsets whose sums are all same. So if the array is like [4, 3, 2, 3, 5, 2, 1] and k = 4, then the ... Read More

Prime Arrangements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:57:12

325 Views

We have to find the number of permutations of 1 to n, so the prime numbers are placed at prime indices. The answers may be large, return the answer modulo 10^9 + 7. So if n = 5, then output will be 12. So there will be 12 permutations. one ... Read More

Day of the Year in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:54:48

3K+ Views

Suppose, we have a date in the format “YYYY-MM-DD”. We have to return the day number of the year. So if the date is “2019-02-10”, then this is 41st day of the year.To solve this, we will follow these steps −Suppose D is an array of day count like [0, ... Read More

Number of Equivalent Domino Pairs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:52:45

316 Views

Suppose we have a list of dominos. Each domino has two numbers. Two dominos D[i] = [a, b] and D[j] = [c, d] will be same if a = c and b = d, or a = d and b = c. So one domino can be reversed. We have ... Read More

Top K Frequent Words in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:52:40

584 Views

Suppose we have a non-empty list of words; we have to find the k most frequent elements. our answer should be sorted by frequency from highest to lowest. When two words have the same frequency, then the word with the lower alphabetical order will be placed at first. So if ... Read More

Distribute Candies to People in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 07:45:56

1K+ Views

Suppose we want to distribute some number of candies to a row of n people in the following way −We then give 1 candy to the first people, 2 candies to the second people, and so on until we give n candies to the last people.After that, we go back ... Read More

Number of Longest Increasing Subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:38:00

420 Views

Suppose we have one unsorted array of integers. we have to find the number of longest increasing subsequence, so if the input is like [1, 3, 5, 4, 7], then the output will be 2, as increasing subsequence are [1, 3, 5, 7] and [1, 3, 4, 7]To solve this, ... Read More

Advertisements