Arnab Chakraborty has Published 4452 Articles

Program to find string after deleting k consecutive duplicate characters in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 07:02:09

792 Views

Suppose we have a string s and another value k, we repeatedly delete the earliest k consecutive duplicate characters, and return the final string.So, if the input is like s = "paaappmmmma" k = 3, then the output will be "ma", as when we delete three "a"s to get "pppmmmma". ... Read More

Program to convert gray code for a given number in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:59:12

636 Views

Suppose we have a number n, we have to find the gray code for that given number (in other words nth gray code). As we know the gray code is a way of ordering binary numbers such that each consecutive number's values differ by exactly one bit. Some gray codes ... Read More

Program to recover shuffled queue of people in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:57:07

86 Views

Suppose we have a 2D matrix where each row contains two values [height, count] these indicates the person has given height and there are 'count' number of people in front of them that are at least as tall as them. Now consider this queue is shuffled, we have to recover ... Read More

Program to find number of distinct quadruple that forms target sum in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:52:43

287 Views

Suppose we have four lists of numbers A, B, C, and D, and also have a target value, we have to find the number of distinct quadruple (i, j, k, l) such that A[i] + B[j] + C[k] + D[l] is same as target.So, if the input is like A ... Read More

Program to find state of prison cells after k days in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:50:07

312 Views

Suppose we have a binary list (1s and 0s in the list) and another value k. Each value in nums represents the state of a prison cell where 1 indicates occupied cell and 0 indicates empty cell. On each day when a cell has two adjacent cells that are either ... Read More

Program to check whether list can be partitioned into pairs where sum is multiple of k in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:45:27

52 Views

Suppose we have a list of numbers called nums and another value k, we have to check whether the list can be partitioned into pairs such that the sum of each pair is divisible by k.So, if the input is like nums = [4, 7, 2, 5] k = 6, ... Read More

Program to find number of sublists we can partition so given list is sorted finally in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:42:41

106 Views

Suppose we have a list of numbers called nums. We can partition the list into some individual sublists then sort each piece. We have to find the maximum number of sublists we can partition to such that nums as a whole is sorted afterwards.So, if the input is like nums ... Read More

Program to find number of ways we can split a palindrome in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:40:20

285 Views

Suppose we have a string s, we have to find the number of ways we can partition the string such that each part is a palindrome.So, if the input is like s = "xyyx", then the output will be 3, as we have splits like: ["x", "yy", "x"], ["x", "y", ... Read More

Program to generate all possible strings by taking the choices in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:36:28

318 Views

Suppose we have a string s of lowercase alphabet characters, other characters like "[", "|", and "]". Here "[a|b|c]" indicates either "a", "b", or "c" can be chosen as a possibility. We have to find a list of strings containing all possible values that s can represent. Here "[]" cannot ... Read More

Program to find minimum possible maximum value after k operations in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 06:30:47

819 Views

Suppose we have a list of numbers called nums and another value k. Now let us consider an operation where we can subtract 1 from any element in the list. We can perform this operation k times. We have to find the minimum possible maximum value in the list after ... Read More

Advertisements