Arnab Chakraborty has Published 4293 Articles

Program to check if we reverse sublist of one list to form second list or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:41:16

224 Views

Suppose we have two lists of numbers called A, and B. We have to take some sublist in A and reverse it. Then check whether it is possible to turn A into B or not. We can take sublist and reverse it any number of times.So, if the input is ... Read More

Program to check the string is repeating string or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:39:32

162 Views

Suppose we have a string, we have to check whether it's a repeating string or not.So, if the input is like string = "helloworldhelloworld", then the output will be TrueTo solve this, we will follow these steps −n := size of sDefine a function findFactors() . This will take nf ... Read More

Program to count k length substring that occurs more than once in the given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:36:43

217 Views

Suppose we have a string s and a number k, we have to find the number of k-length substrings of s, that occur more than once in s.So, if the input is like s = "xxxyyy", k = 2, then the output will be 2To solve this, we will follow ... Read More

Program to find sum of digits until it is one digit number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:34:42

4K+ Views

Suppose we have a positive number n, we will add all of its digits to get a new number. Now repeat this operation until it is less than 10.So, if the input is like 9625, then the output will be 4.To solve this, we will follow these steps −Define a ... Read More

Program to check one string can be converted to another by removing one element in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:33:00

173 Views

Suppose we have two strings s and t, we have to check whether we can get t by removing 1 letter from s.So, if the input is like s = "world", t = "wrld", then the output will be True.To solve this, we will follow these steps −i:= 0n:= size ... Read More

Program to find duplicate elements and delete last occurrence of them in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:31:41

350 Views

Suppose we have a list of numbers A, we have to find all duplicate numbers and remove their last occurrences.So, if the input is like [10, 30, 40, 10, 30, 50], then the output will be [10, 30, 40, 50]To solve this, we will follow these steps −seen:= a new ... Read More

Program to count number of elements present in a set of elements with recursive indexing in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:29:51

243 Views

Suppose we have a list of numbers called A and another number k, we have to make a new set of possible elements {A[k], A[A[k]], A[A[A[k]]], ... } stopping before it's out of index. We have to find the size of this set, otherwise -1 when there is a cycle.So, ... Read More

Program to find the index of first Recurring Character in the given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:28:37

368 Views

Suppose we have a string s, we have to find the index of the first recurring character in it. If we cannot find no recurring characters, then return -1.So, if the input is like "abcade", then the output will be 3, as 'a' is again present at index 3.To solve ... Read More

Program to check two rectangular overlaps or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:26:20

4K+ Views

Suppose we have a rectangle that is represented as a list with four elements [x1, y1, x2, y2], where (x1, y1) is the coordinates of its bottom-left corner, and (x2, y2) is the coordinates of its top-right corner. Two rectangles overlap when the area of their intersection is positive. So, ... Read More

Program to check if the given list has Pythagorean Triplets or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2020 13:24:11

1K+ Views

Suppose we have a list of numbers called nums, we have to check whether there exist three numbers a, b, and c such that a^2 + b^2 = c^2.So, if the input is like [10, 2, 8, 5, 6], then the output will be True, as 8^2 + 6^2 = ... Read More

Advertisements