Arnab Chakraborty has Published 4452 Articles

Program to find number of ways we can reach to the next floor using stairs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:50:10

123 Views

Suppose there is a stair case with N steps. One can either go step by step, or at each step, one can take a jump of at most N steps. We have to find the number of ways in which we can go to the top floor. The N value ... Read More

Program to find lexicographically smallest string to move from start to destination in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:47:12

146 Views

Suppose we are at at (0, 0) position in the Cartesian plane. We want to go to the point (x, y) using only horizontal(H) and vertical(V) moves of single unit. There are more than one possible ways to reach destination. Each way comprises of few H moves and few V ... Read More

Program to find n length string made of letters from m sized alphabet with no palindrome in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:43:36

248 Views

Suppose we have m number of letters and another value n. We have to count number of strings of length n created with letters by taking from these m letters, and string has no palindromic substring of length greater than 1. If answer is too large then mod the result ... Read More

Program to find number of consecutive subsequences whose sum is divisible by k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:41:10

539 Views

Suppose we have an array nums and a value k. We have to find number of consecutive subsequences whose sum is divisible by k.So, if the input is like k = 3 nums = [1, 2, 3, 4, 1], then the output will be 4 because the subsequences are [3], ... Read More

Program to find number of pairs (i, j) such that ith and jth elements are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:37:43

178 Views

Suppose we have an array nums. We have to find number of pairs (i, j) are there such that nums[i] = nums[j] but i is not same as j.So, if the input is like nums = [1, 3, 1, 3, 5], then the output will be 4, because the pairs ... Read More

Program to find sum of differences between max and min elements from randomly selected k balls from n balls in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:35:10

99 Views

Suppose we have n balls which are numbered by an array nums, whose size is n and nums[i] represents the number of ball i. Now we have another value k. In each turn we pick k balls from n different balls and find the difference of maximum and minimum values ... Read More

Program to find number of ways we can merge two lists such that ordering does not change in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:30:58

117 Views

Suppose we have two lists nums1 and nums2. Now the constraint is when we merge the order of elements in each list does not change, for example, if the elements are [1, 2, 3] and [4, 5, 6], then some valid merged lists are [1, 4, 2, 3, 5, 6] ... Read More

Program to find list of all possible combinations of letters of a given string s in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Oct-2021 06:27:49

6K+ Views

Suppose we have a string s. We have to find all possible combinations of letters of s. If there are two strings with same set of characters, then show the lexicographically smallest of them. And one constraint is each character in s are unique.So, if the input is like s ... Read More

Program to find number of ways we can get n R.s using Indian denominations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:53:32

141 Views

Suppose we have limited coins of denominations (₹1, ₹2, ₹5 and ₹10). We have to find in how many ways can you sum them up to a total of ₹n? We have an array count of size 4, where count[0] indicates coins of ₹1, count[1] indicates coins of ₹2 and ... Read More

Program to find nCr values for r in range 0 to n, in an efficient way in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Oct-2021 08:49:26

508 Views

Suppose we have to calculate nCr values many times. We can solve this very efficient way. If we store the lower values of nCr we can easily find higher values. So if we have n, we have to find list of nC0 to nCn. If answer is too large then ... Read More

Advertisements