Arnab Chakraborty has Published 4282 Articles

Check if a given string is a rotation of a palindrome in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 09:15:13

364 Views

Here we will see, one string is palindrome after certain rotation or not. A palindrome is a string that is the same in both directions. A string rotation is a palindrome if that is like AAAAD. this is not a palindrome directly, but its rotation AADAA is a palindrome.To check ... Read More

Check if a given number is sparse or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 09:12:24

618 Views

In this section, we will see how to check a number is sparse or not. A number is said to be sparse if the binary representation of the number, has no two or more than two consecutive 1s. Suppose a number is like 72. This is 01001000. Here no two ... Read More

Check if a given matrix is sparse or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 09:08:18

509 Views

Here we will see how to check whether a matrix is sparse or not. A sparse matrix is a matrix where most of the elements are 0. The definition of a sparse matrix is, if the 2/3rd of the elements are 0, then the matrix is denoted as a sparse ... Read More

Check if a given array is pairwise sorted or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 09:04:02

198 Views

We have an array A, with n elements. We have to check whether the array is pairwise sorted or not. Suppose the array is like {8, 10, 18, 20, 5, 15}. This is pairwise sorted as (8, 10), (18, 20), (5, 15) are sorted. If the array has an odd ... Read More

Check if a circle lies inside another circle or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 09:01:17

646 Views

Suppose we have two circles (center points, and the radius values), we have to check one circle is fit inside another circle or not. There are three possible causes.The smaller circle lies completely inside the bigger one, without touching each other. In this case, the sum of the distance between ... Read More

Check if a binary string contains consecutive same or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 08:58:08

341 Views

Suppose we have a binary string. Our task is to check whether the string has consecutive same characters or not. If there are consecutive same characters, then that is invalid, otherwise valid. Then the string “101010” is valid, but “10111010” is invalid.To solve this problem, we will traverse from left ... Read More

Check if a + b = c is valid after removing all zeroes from a, b and c in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 08:53:27

126 Views

Suppose we have three numbers a, b, c, we have to check whether a + b = c, after removing all 0s from the numbers or not. Suppose the numbers are a = 102, b = 130, c = 2005, then after removing 0s, the numbers will be a + ... Read More

Check if a number is sandwiched between primes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 08:49:00

110 Views

Here we will see whether a number is sandwiched between primes or not. A number is said to be sandwiched between primes when the number just after it, and just below it is prime numbers. To solve this, check whether n-1 and n+1 are prime or not.Example Live Demo#include #include ... Read More

Check if a number is magic (Recursive sum of digits is 1) in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 08:46:25

2K+ Views

Here we will see one program, that can check whether a number is magic number or not. A number is said to be magic number, when the recursive sum of the digits is 1. Suppose a number is like 50311 = 5 + 0 + 3 + 1 + 1 ... Read More

Check for integer overflow on multiplication in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2019 08:25:08

2K+ Views

Suppose we want to find the result after multiplying two numbers A and B. We have to check whether the multiplied value will exceed the 64-bit integer or not. If we multiply 100, and 200, it will not exceed, if we multiply 10000000000 and -10000000000, it will overflow.To check this, ... Read More

Advertisements