Arnab Chakraborty has Published 4293 Articles

Program to merge two sorted list to form larger sorted list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:31:29

227 Views

Suppose we have two sorted lists A and B. We have to merge them and form only one sorted list C. The size of lists may different.For an example, suppose A = [1, 2, 4, 7] and B = [1, 3, 4, 5, 6, 8], then merged list C will ... Read More

Program to split a list of numbers such that the absolute difference of median values are smallest in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:29:13

165 Views

Suppose we have a list of numbers called nums, we have to divide it into two parts of same size where the absolute difference between each list's median is as small as possible and we have to find this difference. We have to keep in mind that here length of ... Read More

Program to count how many times we can find "pizza" with given string characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:27:07

185 Views

Suppose we have a lowercase string s, we have to find how many "pizza" strings we can make using the characters present in s. We can use the characters in s in any order, but each character can be used once.So, if the input is like "ihzapezlzzilaop", then the output ... Read More

Program to equal two strings of same length by swapping characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:25:37

609 Views

Suppose we have two strings s and t of length n. We can take one character from s and another from t and swap them. We can make unlimited number of swaps; we have to check whether it's possible to make the two strings equal or not.So, if the input ... Read More

Program to find length of substring with consecutive common characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:23:26

542 Views

Suppose we have a string s, we have to find the length of the longest substring with same characters.So, if the input is like "abbbaccabbbba", then the output will be 4, as there are four consecutive b's.To solve this, we will follow these steps −if size of s is 0, ... Read More

Program to find longest common prefix from list of strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:21:16

2K+ Views

Suppose we have a list of lowercase strings, we have to find the longest common prefix.So, if the input is like ["antivirus", "anticlockwise", "antigravity"], then the output will be "anti"To solve this, we will follow these steps −sort the list words alphabeticallyprefix := a new listflag := 0for i in ... Read More

Program to replace each element by smallest term at left side in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:19:25

249 Views

Suppose we have a list of numbers called nums, we have to replace every nums[i] with the smallest element left of i. We have to replace nums[0] with 0.So, if the input is like [15, 7, 9, 16, 12, 25], then the output will be [0, 15, 7, 7, 7, ... Read More

Program to make all elements equal by performing given operation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:17:37

526 Views

Suppose we have given a list of numbers called nums, we want to make the values equal. Now let an operation where we pick one element from the list and increment every other value. We have to find the minimum number of operations required to make element values equal.So, if ... Read More

Program to perform given operation with each element of a list and given value in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:16:14

361 Views

Suppose we have a list of numbers called nums, we also have another string op representing operator like "+", "-", "/", or "*", and another value val is also given, we have to perform the operation on every number in nums with val and return the result.So, if the input ... Read More

Program to convert Linked list representing binary number to decimal integer in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:14:23

2K+ Views

Suppose we have a singly linked list. the linked list is representing a binary number with most significant digits first, we have to return it as decimal number.So, if the input is like [1, 0, 1, 1, 0], then the output will be 22To solve this, we will follow these ... Read More

Advertisements