Check If It Is a Good Array in C++

Arnab Chakraborty
Published on 04-Jun-2020 15:16:43
Suppose we have an array called nums of positive integers. We have to select some subset of nums, then multiply each element by an integer and add all these numbers. The array will be a good array if we can get a sum of 1 from the array by any ... Read More

Find the list elements starting with specific letter in Python

Pradeep Elance
Published on 04-Jun-2020 15:15:26
In this article we will find all those elements from a list which start with specific letter.With index and lowerWe use the lower function so that the test later can match with the first letter of the the elements in the list irrespective of the case. Then we use the ... Read More

Tiling a Rectangle with the Fewest Squares in C++

Arnab Chakraborty
Published on 04-Jun-2020 15:13:33
Suppose we have a rectangle of size n x m. We have to find the minimum number of integers sided square objects that can tile the rectangles.So, if the input is like n = 2 and m = 3, then the output will be 3, as we need three blocks.To ... Read More

Find most frequent element in a list in Python

Pradeep Elance
Published on 04-Jun-2020 15:13:29
In this article we will see how to find the element which is most common in a given list. In other words, the element with highest frequency.With max and countWe apply why the set function to get the unique elements of the list and then keep account of each of ... Read More

Find most common element in a 2D list in Python

Pradeep Elance
Published on 04-Jun-2020 15:12:03
A 2D list has list as its element. In other words it is a list of lists. In this article we are required to find the element which is most common among all the lists inside a list.With max and countWe design a follow with a in condition to check ... Read More

Find maximum value in each sublist in Python

Pradeep Elance
Published on 04-Jun-2020 15:09:50
We are given a list of lists. In the inner lists or sublists we are required to find the maximum value in each.With max and inWe design a for loop with in condition and apply the max function to get the maximum value in each of the sublist.Example Live DemoAlist = ... Read More

Maximum Profit in Job Scheduling in C++

Arnab Chakraborty
Published on 04-Jun-2020 15:09:38
Suppose we have n different tasks, where every task is scheduled to be done from startTime[i] to endTime[i], for that task we algo get profit of profit[i]. We know the startTime , endTime and profit lists, we have to find the maximum profit we can take such that there are ... Read More

Count tuples occurrence in list of tuples in Python

Pradeep Elance
Published on 04-Jun-2020 15:08:09
A list is made up of tuples as its element. In this article we will count the number of unique tuples present in the list.With defaultdictWe treat the given list as a defaultdict data container and count the elements in it using the in condition.Example Live Demoimport collections Alist = [[('Mon', ... Read More

Maximum Equal Frequency in C++

Arnab Chakraborty
Published on 04-Jun-2020 15:05:51
Suppose we have an array nums of positive integers, we have to return the longest possible length of an array prefix of given array nums, such that it is possible to delete exactly one element from this prefix so that every number that has appeared in it will have the ... Read More

Count the sublists containing given element in a list in Python

Pradeep Elance
Published on 04-Jun-2020 15:05:37
The elements in a given list can also be present as another string in another variable. In this article we'll see how many times a given stream is present in a given list.With range and lenWe use the range and len function to keep track of the length of the ... Read More
Advertisements