Arnab Chakraborty has Published 4293 Articles

Contains Duplicate III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 07:11:25

329 Views

Suppose we have an array of integers, we have to check whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t. And the absolute difference between i and j is at most k. So if ... Read More

Bitwise AND of Numbers Range in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 07:06:53

891 Views

Suppose we have a range [m, n] where 0 >= 1;          i++;       }       return m

Repeated DNA Sequences in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 06:59:41

1K+ Views

Suppose we have a DNA sequence. As we know, all DNA is composed of a series of nucleotides abbreviated such as A, C, G, and T, for example: "ACGAATTCCG". When we are studying DNA, it is sometimes useful to identify repeated sequences within the DNA.We have to write one method ... Read More

Compare Version Numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 06:51:39

3K+ Views

Suppose we have to compare two version numbers version1 and version2. If the version1 > version2 then return 1; otherwise when version1 < version2 return -1; otherwise return 0. We can assume that the version strings are non-empty and contain only digits and the dot (.) characters. The dot character ... Read More

Lexicographical Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 06:48:59

3K+ Views

Suppose we have an integer n. We have to return 1 to n in lexicographic order. So for example when 13 is given, then the output will be [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9].To solve this, we will follow these steps −define one ... Read More

Range Sum Query 2D - Immutable in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 06:35:50

401 Views

Suppose we have a 2D matrix called matrix, we have to find the sum of the elements inside the rectangle defined by its upper left corner using (row1, col1) and lower right corner using (row2, col2).So if the matrix is like −3014256321120154101710305The above rectangle with the blue color defined by ... Read More

Remove Zero Sum Consecutive Nodes from Linked List in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 15:51:36

2K+ Views

Suppose we have given the head of a linked list; we have to repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. So after doing so, we have to return the head of the final linked list. So if the list is like ... Read More

Swap For Longest Repeated Character Substring in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 15:46:05

562 Views

Suppose we have a string text, so we are allowed to swap two of the characters in the string. We have to find the length of the longest substring with repeated characters. So if the input is like “ababa”, then the result will be 3, as if we swap first ... Read More

Longest Common Subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 15:41:22

458 Views

Suppose we have two strings text1 and text2, we have to return the length of their longest common subsequence. The ubsequence of a string is a new string generated from the original string with some characters deleted without changing the relative order of the remaining characters. (So for example "abe" ... Read More

Maximum of Absolute Value Expression in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 15:36:17

775 Views

Suppose we have two arrays of integers with equal lengths, we have to find the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|. Where the maximum value is taken over all 0

Advertisements