Arnab Chakraborty has Published 4293 Articles

Occurrences After Bigram in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:45:32

172 Views

Suppose there are words given. These are first and second, consider occurrences in some text of the form "first second third", here second comes immediately after the first, and third comes immediately after the second.For each such cases, add "third" into the answer, and show the answer. So if the ... Read More

Last Stone Weight in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:36:07

1K+ Views

Suppose we have some rocks, each rock has a positive integer weight. In each turn, we will take two heaviest rocks and smash them together. consider the stones have weights x and y and x 1:          stones.sort()          s1, s2=stones[-1], stones[-2]     ... Read More

Two City Scheduling in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:33:00

501 Views

Suppose there are 2N persons. A company wants to organize one interview. The cost for flying the i-th person to city A is costs[i][0], and the cost for flying the i-th person to city B is costs[i][1]. We have to find the minimum cost to fly every person to a ... Read More

Partition Array Into Three Parts With Equal Sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:30:30

453 Views

Suppose we have an array A of integers, our output will be true if and only if we can partition the array into three non-empty parts whose sum is equal.Formally, we can partition the array if we can find the indexes i+1 < j with (A[0] + A[1] + ... ... Read More

Pairs of Songs With Total Durations Divisible by 60 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:27:04

2K+ Views

Suppose we have a list of songs, the i-th song has a duration of time[i] seconds. We have to find the number of pairs of songs for which their total time in seconds is divisible by 60.So if the time array is like [30, 20, 150, 100, 40], then the ... Read More

Sum of Even Numbers After Queries in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:19:35

3K+ Views

Suppose we have an array of integers called A, and an array queries. For the i-th query value = queries[i][0] and index = queries[i][1], we will add value to A[index]. Then, the answer of the i-th query is the sum of the even values of A. We have to find ... Read More

Long Pressed Name in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 17:17:37

288 Views

Suppose a man is typing some name on keyboard. Sometimes some buttons are long-pressed by mistake. So it may type one or more extra character. So we will take two strings, and check whether the second string is long-pressed name or not. So if the name is “Amit”, and second ... Read More

Letter Case Permutation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:50:02

282 Views

Suppose we have a string with letters and numbers. We have to generate all possible combinations of that string by taking uppercase and lowercase versions of letters that are present in the string. So if one string has only numbers, only that will be returned. Suppose the string is like ... Read More

Jewels and Stones in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:46:58

731 Views

Suppose we have a string J that indicates some letters that are considered as Jewel, and another string S, that represents some stones that we have. Our task is to find how many of stones in S is also jewel. The letters in J and S are case sensitive. So ... Read More

Diameter of Binary Tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 16:41:03

586 Views

Suppose we have a binary tree; we have to compute the length of the diameter of the tree. The diameter of a binary tree is actually the length of the longest path between any two nodes in a tree. This path not necessarily pass through the root. So if the ... Read More

Advertisements