Arnab Chakraborty has Published 4293 Articles

Program to remove duplicate characters from a given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:08:33

8K+ Views

Suppose we have a string s. We have to remove all duplicate characters that have already appeared before. The final string will have same ordering of characters like the actual one.We can solve this by using ordered dictionary to maintain the insertion order of the characters. The value will be ... Read More

Python program to check credit card number is valid or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:05:26

3K+ Views

Suppose we have a credit card number. We have to check whether the card number is valid or not. The card numbers have certain properties −It will start with 4, 5 and 6It will be 16 digits’ longNumbers must contain only digitsIt may have digits in four groups separated by ... Read More

Program to rotate a string of size n, n times to left in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:04:27

682 Views

Suppose we have a string s of size n. We have to find all rotated strings by rotating them 1 place, 2 places ... n places.So, if the input is like s = "hello", then the output will be ['elloh', 'llohe', 'lohel', 'ohell', 'hello']To solve this, we will follow these ... Read More

Program to find Fibonacci series results up to nth term in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:00:54

470 Views

Suppose we have a number n. We have to find the sum of first n Fibonacci terms (Fibonacci sequence up to n terms). If the answer is too large then return result modulo 10^8 + 7.So, if the input is like n = 8, then the output will be 33 ... Read More

Program to find elements from list which have occurred at least k times in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:57:30

326 Views

Suppose we have a list of elements called nums, and a value k. We have to find those elements which have occurred at least k number of times.So, if the input is like nums = [2, 5, 6, 2, 6, 1, 3, 6, 3, 8, 2, 5, 9, 3, 5, ... Read More

Python program to find product of rational numbers using reduce function

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:56:49

481 Views

Suppose we have a list of rational numbers. We have to find their product using reduce function. The reduce() function applies a function with two arguments cumulatively on a list of objects from left to right.So, if the input is like fractions = [(5, 3), (2, 8), (6, 9), (5, ... Read More

Python program to validate email address

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:53:41

14K+ Views

Suppose we have an email address as string. We have to check whether this is valid or not based on the following conditions −The format must be username@company.domain formatUsername can only contain upper and lowercase letters, numbers, dashes and underscoresCompany name can only contain upper and lowercase letters and numbersDomain ... Read More

Program to find number of ways we can get a number which is sum of nth power of unique numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:42

290 Views

Suppose we have a number x and another number n. We have to find number of ways we can get x as sum of nth power of some unique numbers.So, if the input is like x = 100 n = 2, then the output will be 3 because possible solutions ... Read More

Python program to sort string in custom order

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:07

932 Views

Suppose we have one alphanumeric string s. We have to sort it based on following conditionAll sorted lowercase letters will be placed before uppercase letters.All sorted uppercase letters will be placed before digits.All sorted odd digits will be placed before sorted even digits.So, if the input is like s = ... Read More

Python program to sort table based on given attribute index

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:47:21

419 Views

Suppose we have a 2d list containing information about athletes. This information is rank, age, height. Each row contains information for different athletes. We also have another number k. We have to sort the data based on kth attribute.So, if the input is likeRankageheight125190235180333185426175535180And k = 1.then the output will ... Read More

Advertisements