Arnab Chakraborty has Published 4452 Articles

Program to design a queue that moves the most recently used element to the end of it in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:49:46

404 Views

Suppose, we are asked to design a queue that moves the most recently used element to the end of it. The queue will be initialized with integer numbers 1 to n. Now we have to build a function so that whenever it is called, it moves the value from the ... Read More

Program to find out the sum of the maximum subarray after a operation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:44:21

128 Views

Suppose, we are given an array containing integer numbers. We can perform an operation where we can replace the value of array[i] with its squared value; or array[i] * array[i]. Only one operation of this kind is permitted and we have to return the sum of the maximum possible subarray ... Read More

Program to restore the array from adjacent pairs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:39:28

172 Views

Suppose we have a 2D array called adPair of size n-1 where each adPair[i] has two elements [ui, vi] represents that the elements ui and vi are adjacent in an array called nums, in nums there are n unique elements. We have to find the array nums. If there are ... Read More

Program to find out distance between two nodes in a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:33:05

549 Views

Suppose, we are given a binary tree and are asked to find the distance between two nodes in the binary tree. We find out the edges between the two nodes like in a graph and return the number of edges or the distance between them. A node of a tree ... Read More

Program to find k-th largest XOR coordinate value in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:19:54

111 Views

Suppose we have one m x n matrix. and another value k. Here the value of coordinate (a, b) of the matrix is the XOR of all matrix[i, j] where i in range (0 to a) and j in range (0 to b). We have to find the kth largest ... Read More

Program to change minimum characters to satisfy one of three conditions in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:10:15

124 Views

Suppose we have two strings s and t with only lowercase letters. In one operation, we can change any character in s or t to any lowercase letter. We have to satisfy one of the following three conditions −Every letter in s is strictly smaller than every letter in t ... Read More

Program to find decode XORed permutation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:04:03

152 Views

Suppose we have an array enc. There is an array perm that is a permutation of the first n(odd) positive integers. This list will be encoded into array enc of length n-1, such that enc[i] = perm[i] XOR perm[i+1]. We have to find the original array perm.So, if the input ... Read More

Program to find minimum number of people to teach in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 11:01:44

129 Views

Suppose we have a number n, an array called 'languages', and an array called 'friendships', so there are n languages numbered from 1 through n, languages[i] represents a set of languages the ith user knows, and friendships[i] holds a pair [ui, vi] denotes a friendship between the users ui and ... Read More

Program to find minimum cost to hire k workers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 09:27:16

245 Views

Suppose we have an array called quality for each different worker, and have another array called wages and a value K. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. We want to hire K workers to form a paid group. When we are hiring a group ... Read More

Program to check a string can be split into three palindromes or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 09:22:02

491 Views

Suppose we have a string s. We have to check whether we can split s into three palindromic substring or not.So, if the input is like s = "levelpopracecar", then the output will be True because we can split it like "level", "pop", "racecar", all are palindromes.To solve this, we ... Read More

Advertisements