Arnab Chakraborty has Published 4293 Articles

Linked List Cycle in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 13:22:38

2K+ Views

Consider we have a linked list, and we have to check whether there is any cycle or not. To represent the cycle in the given linked list, we will use one integer pointer called pos. This pos represents a position in the linked list where tail is connected. So if ... Read More

4Sum II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 13:09:00

794 Views

Suppose we have four lists A, B, C, D of integer values, we have to compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. Consider all A, B, C, D have same length of N where 0 ≤ ... Read More

Sort Characters By Frequency in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 13:01:13

2K+ Views

Suppose we have a string, we have to sort the characters based on the frequency. So if the string is like “abbbacbcc”, then the output will be “bbbbcccaa”To solve this, we will follow these steps −create an array of pairs called v, create one map mfor all characters in string, ... Read More

Longest Repeating Character Replacement in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:42:36

2K+ Views

Suppose we have given a string s that consists of only uppercase letters, we can perform at most k operations on that string. In one operation, we can select any character of the string and change it to any other uppercase letters. We have to find the length of the ... Read More

Reconstruct Original Digits from English in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:32:27

405 Views

Suppose we have a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. There are some properties −Input is guaranteed to be valid and can be transformed to its original digits. That means invalid inputs such as "abc" or "zerone" are not permitted.Input ... Read More

Partition Equal Subset Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:28:44

407 Views

Suppose we have a non-empty array containing only positive numbers, we have to find if the array can be partitioned into two subsets such that the sum of elements in both subsets is the same. So if the input is like [1, 5, 11, 5], the output will be true. ... Read More

Queue Reconstruction by Height in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:23:17

353 Views

Consider we have a random list of people standing in a queue. If each person is described by a pair of integers (h, k), where h is the height and k is the number of people in front of him, who have a height greater than or equal to h. ... Read More

Longest Substring with At Least K Repeating Characters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:18:21

298 Views

Suppose we have a string s, and we have to find the length of the longest substring T of that given string (consists of lowercase letters only) such that every character in T appears no less than k times. So if the string is “ababbc” and k = 2, then ... Read More

Decode String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 12:10:27

3K+ Views

Suppose we have an encoded string; we have to return its decoded string. The rule for encoding is: k[encoded_string], this indicates where the encoded_string inside the square brackets is being repeated exactly k times. We can assume that the original data does not contain any numeric characters and that digits ... Read More

Combination Sum IV in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:53:24

276 Views

Suppose we have an integer array with all positive numbers and all elements are unique, find the number of possible combinations, so that if we add up, we will get positive integer target.So if the array is [1, 2, 3] and the target is 4, then the possible combinations will ... Read More

Advertisements