Arnab Chakraborty has Published 4452 Articles

Check if given array is almost sorted (elements are at-most one position away) in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:42:56

228 Views

Suppose we have an array of numbers called nums, where all elements are unique. We have to check whether nums is almost sorted or not. As we know an array is almost sorted when any of its elements can occur at a maximum of 1 distance away from its original ... Read More

Check if frequency of each digit is less than the digit in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:41:28

95 Views

Suppose we have a number n, we have to check whether the occurrence of each digit of n is less than or equal to digit itself.So, if the input is like n = 5162569, then the output will be True as the digits and frequencies are (5, 2), (1, 1), ... Read More

Check if frequency of characters are in Recaman Series in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:36:06

56 Views

Suppose we have a lowercase string s. We have to check whether the occurrences of alphabets in s, after rearranging in any possible manner, generates the Recaman’s Sequence (ignoring the first term).The Recaman’s sequence is as follows −$$a_{n}=\begin{cases}\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:0(if\:n=0) & \a_{n-1}-n(if\:a_{n}-n>0\wedge not\:present\in sequence) & \\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:\:a_{n-1}+n(otherwise)\end{cases}$$Some of the items of Recaman's Sequence ... Read More

Check if frequency of character in one string is a factor or multiple of frequency of same character in other string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:33:36

135 Views

Suppose we have two strings s and t, we have to check whether the occurrences of a character in s is multiple or a factor in t.So, if the input is like s = "xxyzzw" t = "yyyxxxxzz", then the output will be True as frequency of x in s ... Read More

Check if frequency of all characters can become same by one removal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:31:45

456 Views

Suppose we have a lowercase string s. We have to check whether the frequency of all characters are same after deleting one character or not.So, if the input is like s = "abbc", then the output will be True as we can delete one b to get string "abc" where ... Read More

Check If every group of a is followed by a group of b of same length in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:27:59

97 Views

Suppose we have a lowercase string s with only two characters a and b. We have to check whether every group of consecutive a's is followed by group of consecutive b's of equal length.So, if the input is like s = "abaaabbbaabbaabbab", then the output will be True, as all ... Read More

Check if elements of Linked List are present in pair in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:25:44

215 Views

Suppose we have a singly linked list. We have to check whether each element in the given linked list is present in a pair, in other words all elements occur even no. of times.So, if the input is like list = [2, 5, 5, 2, 3, 3], then the output ... Read More

Check if elements of array can be made equal by multiplying given prime numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:23:58

109 Views

Suppose we have two arrays, one is nums and another one is primes. We have to check whether it is possible to make all the elements of nums equal by multiplying one or more prime numbers from primes array.So, if the input is like nums = [25, 100] primes = ... Read More

Check if elements of an array can be arranged satisfying the given condition in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:20:02

200 Views

Suppose we have an array called nums. We have to check whether it is possible to rearrange the elements of nums such that it follows the condition −So, if the input is like nums = [8, -4, 4, -8], then the output will be True as if we arrange the ... Read More

Check if edit distance between two strings is one in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Jan-2021 12:18:01

99 Views

Suppose we have two strings s and t. We have to check whether the edit distance between s and t is exactly one or not. Here edit between two strings means any of these three −Insert a characterDelete a characterReplace a characterSo, if the input is like s = "hello" ... Read More

Advertisements