Arnab Chakraborty has Published 3734 Articles

Minimum Time to Collect All Apples in a Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:22:56

514 Views

Suppose we have an undirected tree consisting of n vertices and these are numbered from 0 to n-1, which has some apples in their vertices. We spend 1 second to walk over one edge of the tree. We have to find the minimum time in seconds we have to spend ... Read More

Count Triplets That Can Form Two Arrays of Equal XOR in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:20:48

314 Views

Suppose we have an array of integers arr. We want to select three indices like i, j and k where (0 = 0; j--) {             x1 = x1 ^ arr[j];             m[x1]++;          }          for (int j = i; j < n; j++) {             x2 = x2 ^ arr[j];             ret += m[x2];          }       }       return ret;    } }; main(){    Solution ob;    vector v = {2,3,1,6,7};    cout

Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit in C++

Arnab Chakraborty

Arnab Chakraborty

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

553 Views

Suppose we have an array of integers called nums and an integer limit, we have to find the size of the longest non-empty subarray such that the absolute difference between any two items of this subarray is less than or equal to the given limit.So, if the input is like ... Read More

Check If All 1's Are at Least Length K Places Away in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:16:26

228 Views

Suppose we have an array nums of 0s and 1s and an integer k, we have to check whether all 1's are at least k places away from each other, otherwise, return False.So, if the input is like nums = [1, 0, 0, 0, 1, 0, 0, 1], k = ... Read More

Check If a String Can Break Another String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:14:52

303 Views

Suppose we have two strings s1 and s2 whose size are same; we have to check whether some permutation of string s1 can break some permutation of string s2 or vice-versa. A string a can break string b if x[i] >= y[i] (in alphabetical order) for all i in range ... Read More

Max Difference You Can Get From Changing an Integer in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:12:39

264 Views

Suppose we have an integer num. We will apply the following steps exactly two times, the steps are like −Pick a digit x in range 0 to 9.Pick another digit y also in range 0 to 9. The digit y can be equal to x.Replace all the occurrences of x ... Read More

Maximum Points You Can Obtain from Cards in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:10:01

360 Views

Suppose there are several cards arranged in a row, each card has associated points, and these points are given in the integer array called cardPoints. In one step, we can take one card from the beginning or from the end of the row. We have to take exactly k cards. ... Read More

Diagonal Traverse II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:08:03

214 Views

Suppose we have a list of lists called nums, we have to show all elements of nums in diagonal order.So, if the input is likethen the output will be [1, 6, 2, 8, 7, 3, 9, 4, 12, 10, 5, 13, 11, 14, 15, 16]To solve this, we will follow ... Read More

Minimum Number of Frogs Croaking in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:03:01

335 Views

Suppose we have a string called croakOfFrogs, this represents a combination of the string "croak" from different frogs, multiple frogs can croak at the same time, so multiple "croak" are mixed. We have to find the minimum number of different frogs to finish all the croak in the given string.Here ... Read More

Display Table of Food Orders in a Restaurant in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Nov-2020 12:00:26

418 Views

Suppose we have an array orders, which represents the orders that customers have done in a restaurant. So, orders[i]=[cust_namei, table_numi, food_itemi] where cust_namei is the customer name, table_numi is the customers table number, and food_itemi is the item customer orders.We have to return the restaurant's “display table”. Here the “display ... Read More

Advertisements