Arnab Chakraborty has Published 4293 Articles

Remove One to Make Average k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:25:01

165 Views

Suppose we have a list of numbers called nums and an integer k, we have to check whether we can remove exactly one element from the list to make the average equal to exactly k. Now we have to keep in mind that, there are some constraints −2 ≤ n ... Read More

Inverse Factorial in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:23:39

2K+ Views

Suppose we have a number a, we have to find n, such that factorial of n (n!) is same as a. As we know, the factorial n = n * (n - 1) * (n - 2) * ... * 1. If there is no such integer n then return ... Read More

Find Intersecting Intervals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:21:36

3K+ Views

Suppose we have a list of intervals, where each interval is like [start, end] this is representing start and end times of an intervals (inclusive), We have to find their intersection, i.e. the interval that lies within all of the given intervals.So, if the input is like [[10, 110], [20, ... Read More

String Interleaving in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:20:24

1K+ Views

Suppose we have two strings s and t, we have to find two strings interleaved, starting with first string s. If there are leftover characters in a string they will be added to the end.So, if the input is like s = "abcd", t = "pqrstu", then the output will ... Read More

Integer to Base 3 Number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:19:05

3K+ Views

Suppose we have a number n, we have to find the base 3 equivalent of this number as string.So, if the input is like 17, then the output will be 122.To solve this, we will follow these steps −if n

In-place Move Zeros to End of List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:16:15

3K+ Views

Suppose we have a list of numbers nums, we have to put all the zeros to the end of the list by updating the list in-place. And the relative ordering of other elements should not be changed. We have to try to solve this in O(1) additional space.So, if the ... Read More

Index into an Infinite String in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:14:26

462 Views

Suppose we have a string s and two integers i and j (i < j). Now suppose p is an infinite string of s repeating forever. We have to find the substring of p from indexes [i, j).So, if the input is like s = "programmer", i = 4, j ... Read More

Count Frequency of Highest Frequent Elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:09:58

2K+ Views

Suppose we have a list of numbers called nums, we have to find the most frequently present element and get the number of occurrences of that element.So, if the input is like [1, 5, 8, 5, 6, 3, 2, 45, 7, 5, 8, 7, 1, 4, 6, 8, 9, 10], ... Read More

Insert 5 to Make Number Largest in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:08:28

505 Views

Suppose we have a number n, we have to find the maximum number we can make by inserting 5 anywhere in the number.So, if the input is like n = 826, then the output will be 8526.To solve this, we will follow these steps −temp := n as a stringans ... Read More

Guess Nearest Square Root in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:01:57

589 Views

Suppose we have a non-negative number n, we have to find a number r such that r * r = n and we have to round down to the nearest integer. We have to solve this problem without using the builtin square-root function.So, if the input is like 1025, then ... Read More

Advertisements