Arnab Chakraborty has Published 4452 Articles

Check if a string has all characters with same frequency with one variation allowed in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:16:11

122 Views

Suppose we have a lowercase string s, we have to check whether we can convert s into a valid string by deleting at most 1 character. Here a valid string means a string str such that for all unique characters in str each character’s frequency is same.So, if the input ... Read More

Check if a string follows a^n b^n pattern or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:14:02

147 Views

Suppose we have a string s we have to check whether the string is following the pattern a^nb^n or not. This is actually a string when n = 3, the string will be "aaabbb".So, if the input is like s = "aaaaabbbbb", then the output will be True as this ... Read More

Check if a string contains a palindromic sub-string of even length in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:12:42

338 Views

Suppose we have a string s. We have to check whether this string contains some even length palindrome or not.So, if the input is like s = "afternoon", then the output will be True as "afternoon" has even length palindrome "noon".To solve this, we will follow these steps:for i in ... Read More

Check if a string can become empty by recursively deleting a given sub-string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:11:47

308 Views

Suppose we have two strings s and t. We can delete t from s any number of times. And t appears only once at a time. We have to check whether s can become empty by removing t as many times as required.So, if the input is like s = ... Read More

Check if a string can be repeated to make another string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:10:20

369 Views

Suppose we have two strings s and t, we have to find how many times the string s can be concatenated to generate t. If we cannot generate t using s, then return -1.So, if the input is like s = "tom" t = "tomtomtom", then the output will be ... Read More

Check if a string can be obtained by rotating another string 2 places in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:07:59

209 Views

Suppose we have two strings s and t. We have to check whether we can get s by rotating t two place at any direction left or right.So, if the input is like s = "kolkata" t = "takolka", then the output will be True as we can rotate "takolka" ... Read More

Check if a string can be formed from another string using given constraints in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:06:50

237 Views

Suppose we have two strings lowercase strings s and t. We have to check whether t can be generated from s using following constraints or not −Characters of t is there in s for example if there are two 'a' in t, then s should also have two 'a's.When any ... Read More

Check if a string can be converted to another string by replacing vowels and consonants in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:05:33

280 Views

Suppose we have two strings s and t. We can only change a character at any position to any vowel if it is already a vowel or to a consonant if it is already a consonant. We have to check whether s can be represented to t or vice-versa.So, if ... Read More

Check if a sorted array can be divided in pairs whose sum is k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:03:30

78 Views

Suppose we have an array of numbers and have another number k, we have to check whether given array can be divided into pairs such that the sum of every pair is k or not.So, if the input is like arr = [1, 2, 3, 4, 5, 6], k = ... Read More

Check if a queue can be sorted into another queue using a stack in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Dec-2020 13:02:15

213 Views

Suppose we have a Queue with first n natural numbers (unsorted). We have to check whether the given Queue elements can be sorted in non-decreasing sequence in another Queue by using a stack. We can use following operations to solve this problem −Push or pop elements from stackDelete element from ... Read More

Advertisements