Arnab Chakraborty has Published 4293 Articles

Maximum Swap in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:32:59

1K+ Views

Suppose we have a non-negative integer; we could swap two digits at most once to get the maximum valued number. We have to return the maximum valued number we can get. So if the input is like 2736 then the output will be 7236. So here we are swapping 2 ... Read More

Find K Closest Elements in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:29:19

462 Views

Suppose we have a sorted array, two integers k and x are also given, we have to find the k closest elements to x in that array. The result should be sorted in increasing order. If there is a tie, the smaller elements are always preferred. So if the input ... Read More

Palindromic Substrings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:12:53

6K+ Views

Suppose we have a string; we have to count how many palindromic substrings present in this string. The substrings with different start indices or end indices are counted as different substrings even they consist of same characters. So if the input is like “aaa”, then the output will be 6 ... Read More

Delete Operations for Two Strings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:09:36

291 Views

Suppose we have two words w1 and w2, we have to find the minimum number of steps required to make w1 and w2 the same, where in each step we can delete one character in either string. So if the input is like “sea” and “eat”, then the output will ... Read More

Permutation in String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 06:00:06

702 Views

Suppose we have two strings s1 and s2, we have to write a function to return true if s2 contains the permutation of s1. So we can say that one of the first string's permutations is the substring of the second string. So if the string s1 = “abc”, and ... Read More

Subarray Sum Equals K in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 05:56:41

785 Views

Suppose we have an array of integers and an integer k, we need to find the total number of continuous subarrays whose sum same as k. So if nums array is [1, 1, 1] and k is 2, then the output will be 2.To solve this, we will follow these ... Read More

Single Element in a Sorted Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 05:54:10

386 Views

Suppose we have a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. we have to find this single element that appears only once. So if the array is like [1, 1, 2, 3, 3, 4, 4, 8, 8], ... Read More

Coin Change 2 in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 05:51:30

516 Views

Suppose we have coins of different denominations and a total amount of money. we have to Write a module to compute the number of combinations that make up that amount. we can assume that we have infinite number of each kind of coin. So if the amount is 5 and ... Read More

Next Greater Element II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 05:46:18

241 Views

Suppose we have a circular array (the next element of the last element is the first element of the array), we have to display the Next Greater Number for every element. Here the Next Greater Number of a number x is the first greater number to its traversing-order next in ... Read More

Target Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Apr-2020 05:41:25

713 Views

Suppose we have a list of non-negative integers, a1, a2, ..., an, and another value, that is target, S. Now we have 2 symbols + and -. For each integer, we should choose one from + and - as its new symbol. we have to find out how many ways ... Read More

Advertisements