Arnab Chakraborty has Published 4293 Articles

Program to find largest size to truncate logs to store them completely in database in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:21:36

127 Views

Suppose we have a list of numbers called logs and another value limit. Each element in logs[i] represents the size of logs generated by the i-th user. And limit represents the total size of logs we can store in our database. We have to find the largest x such that ... Read More

Program to find minimum length of first split of an array with smaller elements than other list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:19:28

189 Views

Suppose we have a list of numbers nums, we want to split the list into two parts part1 and part2 such that every element in part1 is less than or equal to every element in part1. We have to find the smallest length of part1 that is possible (not 0 ... Read More

Program to count number of on lights flipped by n people in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:17:19

196 Views

Suppose we have a number n, consider there are n toggle switches in a room and there are n people present in that room, they flip switches as follows −Person 1 comes and flips all switches.Person 2 comes and flips switches that are multiples of 2: 2, 4, 6, ...Person ... Read More

Program to find lexicographically smallest lowercase string of length k and distance n in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:13:24

356 Views

Suppose we have two numbers n and k. We have to find the lexicographically smallest lowercase string of size k and distance n. The distance is the sum of the letter number in alphabet. For example, 'a' has letter number 1, 'b' has 2, 'y' has 25, 'z' has 26 ... Read More

Program to find length of the longest path in an n-ary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:11:56

434 Views

Suppose we have an edge list where each items are holding (u, v) represents u is parent of v. We have to find the length of the longest path in the tree. The path length is 1 + number of nodes in that path.So, if the input is likethen the ... Read More

Program to find area of largest submatrix by column rearrangements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:07:15

271 Views

Suppose we have a binary matrix. We can first rearrange the columns as many times as we want, then find return the area of the largest submatrix containing only 1s.So, if the input is like100111101then the output will be 4, because we can arrange is like −100111110To solve this, we ... Read More

Program to find largest kth index value of one list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:03:28

202 Views

Suppose we have three values n, total, and k. Now consider a list of size n whose sum is same as total and where the absolute difference between any two consecutive elements is at most 1. We have to find the maximum value at index k of such a list.So, ... Read More

Program to find kth smallest element in linear time in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:01:16

2K+ Views

Suppose we have a list of numbers called nums, we also have another value k, we have to find the kth (starting from 0) smallest element in the list. We have to solve this problem in O(n) time on average.So, if the input is like nums = [6, 4, 9, ... Read More

Program to find maximum number of K-sized groups with distinct type items are possible in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 09:59:09

978 Views

Suppose we have a list of numbers called counts where counts[i] represents the number of items are of type i. We also have another value k. We have to find the maximum number of groups of size k we can find, such that each group must have items of distinct ... Read More

Program to count how many blocks are covered k times by walking in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:28:47

315 Views

Suppose we have two lists called walks and target. At the beginning we are at position 0 in a one-dimensional line. Now |walks[i]| represents the number of steps have been walked. And when walk[i] is positive then indicates walked right, and negative for left. When we walk, we move one ... Read More

Advertisements