Arnab Chakraborty has Published 4293 Articles

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

358 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

438 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

1K+ 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

Program to find number of only child in a binary tree in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 13:05:33

531 Views

Suppose we have a binary tree; we have to find the number of nodes that are an only child. As we know a node x is called an only child node when its parent has exactly one child that is x.So, if the input is likethen the output will be ... Read More

Program to find number of swaps required to sort the sequence in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 13:01:41

2K+ Views

Suppose we have a list of distinct numbers; we have to find the minimum number of swaps required to sort the list in increasing order.So, if the input is like nums = [3, 1, 7, 5], then the output will be 2, as we can swap 3 and 1, then ... Read More

Program to find number of sublists whose sum is given target in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 12:59:39

520 Views

Suppose we have a list of numbers called nums and another value target, we have to find the number of sublists whose sum is same as target.So, if the input is like nums = [3, 0, 3] target = 3, then the output will be 4, as we have these ... Read More

Program to find number of K-Length sublists whose average is greater or same as target in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 12:57:25

247 Views

Suppose we have a list nums, and two additional values k and target, we have to find the number of sublists whose size is k and its average value ≥ target.So, if the input is like nums = [1, 10, 5, 6, 7] k = 3 target = 6, then ... Read More

Program to count number of fraction pairs whose sum is 1 in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 12:55:17

2K+ Views

Suppose we have a list of fractions where each fraction is individual lists [numerator, denominator] which represents the number (numerator / denominator). We have to find the number of pairs of fractions whose sum is 1.So, if the input is like fractions = [[2, 7], [3, 12], [4, 14], [5, ... Read More

Program to find number not greater than n where all digits are non-decreasing in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 12:53:29

301 Views

Suppose we have a number n, we have to find the largest number smaller or equal to n where all digits are non-decreasing.So, if the input is like n = 221, then the output will be 199.To solve this, we will follow these steps:digits := a list with all digits ... Read More

Program to find kth smallest n length lexicographically smallest string in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Nov-2020 12:50:44

555 Views

Suppose we have a number n and another value k. Now let us consider a string containing only "0", "1", and "2"s where no character is repeated in succession. We have to select such strings of length n and find the kth lexicographically smallest string. If there is no kth ... Read More

Advertisements