Arnab Chakraborty has Published 4293 Articles

Program to encode a string in normal form to its run-length form in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 06:31:52

474 Views

Suppose we have a string s. We have to encode this by using run-length encoding technique. As we know, run-length encoding is a fast and simple method of encoding strings. The idea is as follows − The repeated successive elements (characters) as a single count and character.So, if the input ... Read More

Program to decode a run-length form of string into normal form in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 06:29:32

2K+ Views

Suppose we have a string s. The s is a run-length encoded string, we have to find the decoded version of it. As we know, run-length encoding is a fast and simple method of encoding strings. The idea is as follows − The repeated successive elements (characters) as a single ... Read More

Program to find how many distinct rotation groups are there for a list of words in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 06:25:34

298 Views

Suppose we have rotation group for a string that holds all of its unique rotations. If the input is like, "567" then this can be rotated to "675" and "756" and they are all in the same rotation group. Now if we have a list of strings words, we have ... Read More

Program to check whether every rotation of a number is prime or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 06:23:26

708 Views

Suppose we have a number n, we have to check whether every rotation of n is prime or not.So, if the input is like n = 13, then the output will be True, as 13 is prime, 31 is also prime.To solve this, we will follow these steps −n := ... Read More

Largest product of contiguous digits in Python

Arnab Chakraborty

Arnab Chakraborty

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

341 Views

Suppose we have two numbers num and k, we have to find the largest product of k contiguous digits in num. We have to keep in mind that num is guaranteed to have >= k digits.So, if the input is like num = 52689762 and k = 4, then the ... Read More

Largest Number By Two Times in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:32:53

286 Views

Suppose we have a list of numbers; we have to check whether the largest number is bigger than the second-largest number by more than two times. As an example, if the list is like [3, 9, 6], then it will return false, as 9 is not bigger than 12 (2 ... Read More

Largest Gap in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:31:10

1K+ Views

Suppose we have a list of numbers called nums, we have to find the largest difference of two consecutive numbers in the sorted version of nums.So, if the input is like [5, 2, 3, 9, 10, 11], then the output will be 4, as the largest gap between 5 and ... Read More

K Prefix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Sep-2020 07:29:49

441 Views

Suppose we have a list of numbers nums and an integer k, we have to find the maximum possible i where nums[0] + nums[1] + ... + nums[i] ≤ k. We will return -1 if no valid i exists.So, if the input is like nums = [4, -7, 5, 2, ... Read More

Knights' Attack in Python

Arnab Chakraborty

Arnab Chakraborty

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

303 Views

Suppose we have a two-dimensional binary matrix, representing a rectangular chess board, here 0 is for empty cell and 1 is for a knight. The knight is able to move two squares away horizontally and one square vertically, or two squares vertically and one square horizontally (like chess board knight). ... Read More

K and -K in Python

Arnab Chakraborty

Arnab Chakraborty

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

772 Views

Suppose we have a list of numbers called nums, we have to find the largest number k where k and -k both exist in nums (they can be the same number). If there's no such element, return -1.So, if the input is like [-5, 2, 9, -6, 5, -9], then ... Read More

Advertisements