Arnab Chakraborty has Published 4452 Articles

Check if binary string multiple of 3 using DFA in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:26:28

1K+ Views

Suppose we have an array n that represents a binary representation of any number. We have to check whether its binary representation is divisible by three or not by using Deterministic Finite Automata DFA.So, if the input is like n = [1, 1, 0, 0] (binary of 12), then the ... Read More

Check if binary representation of a number is palindrome in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:22:22

215 Views

Suppose we have a number n. We have to check whether the binary representation of n is palindrome or not.So, if the input is like n = 9, then the output will be True as binary representation of 9 is 1001, which is palindrome.To solve this, we will follow these ... Read More

Check if array sum can be made K by three operations on it in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:20:44

77 Views

Suppose we have a list of numbers called nums and also a positive value K. We can perform any of these three operations on nums −Make one number negative, Add index (start from index 1) of the number to the number itselfSubtract index of the number from the number itself.Finally, ... Read More

Check if array elements are consecutive in O(n) time and O(1) space (Handles Both Positive and negative numbers) in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:18:32

123 Views

Suppose we have an array of unsorted numbers called nums. We have to check whether it contains contiguous values or not, it should support negative numbers also.So, if the input is like nums = [-3, 5, 1, -2, -1, 0, 2, 4, 3], then the output will be true as ... Read More

Check if array elements are consecutive in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:17:06

5K+ Views

Suppose we have an array of numbers called nums. We have to check whether it contains contiguous values or not.So, if the input is like nums = [6, 8, 3, 5, 4, 7], then the output will be true as the elements are 3, 4, 5, 6, 7, 8.To solve ... Read More

Check if array contains contiguous integers with duplicates allowed in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:15:40

309 Views

Suppose we have an array of numbers called nums, it may have duplicate elements. We have to check whether it is a set of contiguous numbers or not.So, if the input is like nums = [6, 8, 8, 3, 3, 3, 5, 4, 4, 7], then the output will be ... Read More

Check if array can be sorted with one swap in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:14:22

151 Views

Suppose, we are provided with an array that contains integer elements. We have to find out if the values in the array can be sorted in a non-decreasing order if we can perform only one swap operation. If possible, we say it can be done, otherwise not.So, if the input ... Read More

Check if array can be divided into two sub-arrays such that their absolute difference is Ks in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:13:04

66 Views

Suppose, we are provided with an array "input_list" containing integer numbers. The problem given to us is to check if the given array can be divided into two halves, where the difference of the sum of two halves is equal to a number n. The number n will be provided ... Read More

Check if any two intervals overlap among a given set of intervals in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:11:59

665 Views

Suppose, we are given a set of intervals that consists of values (time1, time2) where time1 represents the starting time, and time2 represents the ending time of an event. Our task is to check whether any of these intervals overlap any other interval in this set. If any of the ... Read More

Check if any square (with one colored cell) can be divided into two equal parts in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Dec-2020 13:10:42

74 Views

Suppose, we are provided with a square that is a size of n. The n sized square is further divided into n2 smaller squares. The smaller squares are of unit size and one of the squares is colored with a unique color.Now if we cut the bigger square into two ... Read More

Advertisements