Arnab Chakraborty has Published 4293 Articles

Program to find k-sized list where difference between largest and smallest item is minimum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:55:35

217 Views

Suppose we have a list of numbers called nums and an integer k, we have to select elements from nums to create a list of size k such that the difference between the largest integer in the list and the smallest integer is as low as possible. And we will ... Read More

Program to find the largest grouping of anagrams from a word list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:52:52

237 Views

Suppose we have a list of strings words, we have to group all anagrams together and return the size of the largest grouping.So, if the input is like words = ["xy", "yx", "xyz", "zyx", "yzx", "wwwww"], then the output will be 3, as ["xyz", "zyx", "yzx"] is the largest grouping.To ... Read More

Program to find minimum required chances to form a string with K unique characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:47:31

465 Views

Suppose we have a string s of lowercase alphabet characters, and another number k, we have to find the minimum number of required changes in the string so that the resulting string has at most k distinct characters. In this case The change is actually changing a single character to ... Read More

Program to find the kth missing number from a list of elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:34:28

541 Views

Suppose we have a list of sorted unique numbers called nums and an integer k, we have to find the kth missing number from the first element of the given list.So, if the input is like nums = [5, 6, 8, 10, 11], k = 1, then the output will ... Read More

Program to find the K-th last node of a linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:29:45

1K+ Views

Suppose we have a singly linked list, we have to check find the value of the kth last node (0-indexed). We have to solve this in single pass.So, if the input is like node = [5, 4, 6, 3, 4, 7], k = 2, then the output will be 3, ... Read More

Program to find maximum sum of popped k elements from a list of stacks in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:25:24

335 Views

Suppose we have a list of stacks and an integer k. We have to find the maximum possible sum that can be achieved from popping off exactly k elements from any combination of the stacks.So, if the input is like stacks = [[50, -4, -15], [2], [6, 7, 8]], k ... Read More

Program to find a list of numbers where each K-sized window has unique elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:17:28

284 Views

Suppose we have a list of numbers called nums and another number k, we have to find a list of count of distinct numbers in each window of size k.So, if the input is like nums = [2, 2, 3, 3, 4], k = 2, then the output will be ... Read More

Program to find the perimeter of an island shape in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:13:04

501 Views

Suppose we have a binary matrix where 0 shows empty cell and 1 shows a block that forms a shape, now we have to find the perimeter of the shape. The shape will not hold any hole inside it.So, if the input is like0000000111001100111000000then the output will be 14.To solve ... Read More

Program to interleave list elements from two linked lists in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 14:01:44

533 Views

Suppose we have two linked lists l1 and l2, we have to return one linked list by interleaving elements of these two lists starting with l1. If there are any leftover nodes in a linked list, they should be appended to the list.So, if the input is like l1 = ... Read More

Program to count n digit integers where digits are strictly increasing in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 13:45:58

254 Views

Suppose we have a number n, we have to find the number of n-digit positive integers such that the digits are in strictly increasing order.So, if the input is like n = 3, then the output will be 84, as numbers are 123, 124, 125, ..., 678, 789To solve this, ... Read More

Advertisements