Arnab Chakraborty has Published 4293 Articles

Gray Code in C++

Arnab Chakraborty

Arnab Chakraborty

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

2K+ Views

As we know that the gray code is a binary numeral system where two successive values differ in only one bit. Suppose we have a non-negative integer n representing the total number of bits in the code. We have to print the sequence of gray code. A gray code sequence ... Read More

Partition List in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 05:50:16

626 Views

Suppose we have a linked list and a value x. We have to make partitions. The partition it such that all nodes less than x comes before the nodes that are greater than or equal to x. We should preserve the original relative order of the nodes in each of ... Read More

Combinations in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 14:16:54

1K+ Views

Suppose we have two integers n and k. We have to find all possible combinations of k numbers out of 1 ... n. So if n = 4 and k = 2, then the combinations will be [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]To solve ... Read More

Sort Colors in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 14:12:40

3K+ Views

Suppose we have an array with n objects. These are colored red, white, or blue, sort them in place so that the objects of the same color are adjacent. So with the colors in the order red, white and blue. Here, we will use the numbers like 0, 1, and ... Read More

Spiral Matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 14:09:34

5K+ Views

Suppose we have a matrix and we have to print the matrix elements in a spiral way. At first starting from the first row, print the whole content and then follow the last column to print, then the last row, and so on, thus it prints the elements in a ... Read More

Pow(x, n) in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 13:51:18

2K+ Views

Suppose we have two inputs x and n. x is a number in range -100.0 to 100.0, and n is a 32-bit signed integer. We have to find x to the power n without using library functions.So if the given inputs are x = 12.1, n = -2, then output ... Read More

Rotate Image in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 13:45:13

456 Views

Suppose we have one 2D matrix, that is representing one image. We have to rotate this image to 90 degrees clockwise. So if the image is like157963213Then the output will be291165337To solve this, we will follow these steps −Consider temp_mat = [], col := length of matrix – 1for col ... Read More

Permutations II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 13:26:05

382 Views

Suppose we have a collection of distinct integers; we have to find all possible permutations. Now if the array stores the duplicate elements, then ignore that state which is looking similar. So if the array is like [1, 1, 3], then the result will be [[1, 1, 3], [1, 3, ... Read More

Valid Sudoku in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 13:08:03

5K+ Views

Suppose we have one 9x9 Sudoku board. We have to check whether that is valid or now. Only the filled cells need to be validated according to the following rules −Each row must contain the digits from 1-9 without repetition.Each column must contain the digits from 1-9 without repetition.Each of ... Read More

Find First and Last Position of Element in Sorted Array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Apr-2020 12:59:33

1K+ Views

Suppose we have an array of integers A. This is sorted in ascending order, we have to find the starting and ending position of a given target value. When the target is not found in the array, return [-1, -1]. So if the array is like [2, 2, 2, 3, ... Read More

Advertisements