Python finding programming question in a String

Arnab Chakraborty
Published on 22-Sep-2020 15:07:05
Suppose we have a lowercase string s, we have to check whether it's possible to pick some subsequence of characters in s such that − 1. The difference of any two successive indexes of the characters is same 2. The characters form the string "programmingquestion"So, if the input is like ... Read More

Calculate Factorial in Python

Arnab Chakraborty
Published on 22-Sep-2020 15:03:51
Suppose we have a number n less than or equal to 10, we have to find its factorial. We know that the factorial of a number n is n! = n * (n - 1) * (n - 2) * ... * 1.So, if the input is like 6, then ... Read More

Swap Consecutive Even Elements in Python

Arnab Chakraborty
Published on 22-Sep-2020 15:02:32
Suppose we have a list of numbers called nums, we have to exchange every consecutive even integer with each other.So, if the input is like nums = [4, 5, 6, 8, 10], then the output will be [6, 5, 4, 10, 8]To solve this, we will follow these steps −temp ... Read More

Remove Substrings in One Iteration in python

Arnab Chakraborty
Published on 22-Sep-2020 15:00:48
Suppose we have a string s, we have to remove all “y” and “xz” in the string in one iteration.So, if the input is like s = "xyxxzyyxxzx", then the output will be xxxxTo solve this, we will follow these steps −To solve this, we will follow these steps −temp ... Read More

Pattern After Double, Reverse, and Swap in Python

Arnab Chakraborty
Published on 22-Sep-2020 14:58:14
Suppose we have a number n, we have ot find the nth value from the sequence. The sequence is like below −xxyxxyxxyyxxyxxxyyxyyxyyxyyxyyxyy...To generate the next value, we have to follow these rules, starting with xxy as the first term −When we are at the start of the pattern, double it(concatenate ... Read More

Domino Covering Board in Python

Arnab Chakraborty
Published on 22-Sep-2020 14:56:13
Suppose we have two numbers n and m representing a board of size n x m. We also have an unlimited number of 1 x 2 dominos. We have to find the maximum number of dominos that can be placed on the board such that they don't overlap and every ... Read More

Smallest Distance Between Two Words in Python

Arnab Chakraborty
Published on 22-Sep-2020 14:51:51
Suppose we have two strings, word0, and word1 and a text. We have to find the smallest distance between any two occurrences of word0 and word1 in the given text. Here the distance is measured in number of words. If they are not present in the text then return -1.So, ... Read More

Detect Voter Fraud in Python

Arnab Chakraborty
Published on 22-Sep-2020 14:50:07
Suppose we have a list of votes, where each element in the list has two elements [c_id, v_id], the c_id is the candidate id and v_id is the voter id. We have to check whether any voter has voted more than once or not.So, if the input is like [[5, ... Read More

Is Max Heap in Python?

Arnab Chakraborty
Published on 22-Sep-2020 14:48:17
Suppose we have a list of numbers called nums, we have to check whether it represents a max heap. We will follow these rules −nums[i] = nums[2*i + 1] when 2*i + 1 is inside rangenums[i] = nums[2*i + 2] when 2*i + 2 is inside rangeSo, if the input ... Read More

Swap Even Index Elements And Odd Index Elements in Python

Arnab Chakraborty
Published on 22-Sep-2020 14:45:10
Suppose we have a list of numbers called nums, we will exchange each consecutive even indexes with each other, and also exchange each consecutive odd index with each other.So, if the input is like [1, 2, 3, 4, 5, 6, 7, 8, 9], then the output will be [3, 4, ... Read More
1 2 3 4 5 6 7 ... 4025 Next
Advertisements