Arnab Chakraborty has Published 3734 Articles

Find the maximum distance covered using n bikes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:55:18

597 Views

Suppose there are n bikes and each can cover 100 km when they are fully fueled. We have to find the maximum amount of distance we can go using these n bikes. Here we can assume that all bikes are similar and a bike consumes 1 litre of fuel to ... Read More

Find the maximum cost of an array of pairs choosing at most K pairs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:53:46

233 Views

Suppose we have an array of pairs A; we have to find the maximum cost for selecting at most K pairs. In this case, the cost of an array of pairs type elements is the product of the sum of first elements of the selected pair and the smallest among ... Read More

Find the longest substring with k unique characters in a given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:52:00

702 Views

Suppose we have a string we have to return the longest possible substring that has exactly k number of unique characters, if there are more than one substring of longest possible length, return any of them.So, if the input is like s = "ppqprqtqtqt", k = 3, then the output ... Read More

Find the longest subsequence of an array having LCM at most K in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:49:33

563 Views

Suppose we have an array A of n different numbers and another positive integer K, we have to find the longest sub-sequence in the array having Least Common Multiple (LCM) at most K. After than return the LCM and the length of the sub-sequence, following the indexes (starting from 0) ... Read More

Find the longest sub-string which is prefix, suffix and also present inside the string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:47:16

1K+ Views

Suppose we have a given string, we have to find the largest sub-string which is a prefix, a suffix and a sub-string of that given string. If there is no such substring, then return -1.So, if the input is like "languagepythonlanguageinterestinglanguage", then the output will be "language"To solve this, we ... Read More

Find the lexicographically smallest string which satisfies the given condition in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:44:51

495 Views

Suppose we have an array A of n numbers, where A[i] indicates the number of distinct characters in the prefix of length (i + 1) of a string s, we have to find the lexicographically smallest string that satisfies the given prefix array. All characters will be lowercase English alphabets ... Read More

Find the lexicographically smallest sequence which can be formed by re-arranging elements of second array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:42:47

491 Views

Suppose we have two arrays A and B with n numbers, we have to rearrange the elements of B in itself in a way such that the sequence formed by (A[i] + B[i]) % n after rearranging it is lexicographically smallest. Finally we will return the lexicographically smallest possible sequence.So, ... Read More

Find the lexicographically largest palindromic Subsequence of a String in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:40:13

363 Views

Suppose we have a string S; we have to find the lexicographically largest palindromic subsequence of that string.So, if the input is like "tutorialspointtutorial", then the output will be "uu"To solve this, we will follow these steps −ans := blank stringmax_val := s[0]for i in range 1 to size of ... Read More

Find the last element of a list in scala

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:37:29

898 Views

Suppose we have a list in Scala, this list is defined under scala.collection.immutable package. As we know, a list is a collection of same type elements which contains immutable (cannot be changed) data. We generally apply last function to show last element of a list.Using last keywordThe following Scala code ... Read More

Find the largest rectangle of 1’s with swapping of columns allowed in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 07:34:45

252 Views

Suppose we have a binary matrix, we have to find the largest rectangle of all 1's in that given matrix. The rectangle can be built by swapping or exchanging any pair of columns of that matrix.So, if the input is like100101001111010then the output will be the 6 in this case. ... Read More

Advertisements