Found 26504 Articles for Server Side Programming

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

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

907 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 intervals overlap, we return the result as True, otherwise we return False.So, if the input is like [(4, 7), (5, 11), (7, 11), (5, 8)] then the output will be True.To solve this, we will follow these steps −sort the list inputArrfor i in range 1 to size of inputArr, ... Read More

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

Yaswanth Varma
Updated on 08-Aug-2025 16:17:50

189 Views

Dividing a Square into two Equal Parts In this article, we are given a square of size n*n with exactly one cell coloured. The task is to determine whether this square can be divided into two equal splits by making a single straight cut along the square, ensuring that the coloured cell lies entirely within one of the splits. Two equal splits here indicate that both parts must contain the same number of cells, which is possible if the square side length is even. In this article we are not only checking whether the split is possible but also whether the ... Read More

Check if any permutation of N equals any power of K in Python

Arnab Chakraborty
Updated on 30-Dec-2020 13:09:06

169 Views

Suppose, we have two positive integers n and m, such that 2 ≤ n ≤ 1018 and 2 ≤ m ≤ n. Our goal is to find out if there are any all-digit-permutations of the number n; so that it is equal to some power of m. If there is one, we state that there exists an all-digit-permutation of n that is equal to a power of m, otherwise we state the previous statement as false.For example, we are given n = 7182 and m = 12. As 1728 is an all-digit-permutation of 7182 and 1728 = 12^3, we state ... Read More

Check if any permutation of a number is divisible by 3 and is Palindromic in Python

Yaswanth Varma
Updated on 07-Aug-2025 18:49:53

199 Views

Divisibility by 3 The given task is to determine whether the permutation of the digits of the given number can form a new number that satisfies two conditions: it must be divisible by 3 and also be a palindromic number. A number is said to be palindromic if the reversal of a number is the same as the original, such as 121 or 1331, and a number is said to be divisible by 3 if the sum of its digits is divisible by 3. For example, let's look at the following scenarios:  Scenario 1 Input: 121 Output: False Explanation: ... Read More

Check if any permutation of a large number is divisible by 8 in Python

Yaswanth Varma
Updated on 07-Aug-2025 18:38:46

939 Views

Divisibility By 8 According to the divisibility rule of 8, if the last three digits of a number are divisible by 8, then the entire number is divisible by 8. While this is easy to check for small numbers, when it comes to large numbers, generating all the possible permutations is impractical for large inputs. However, we can solve this problem by taking advantage of the divisibility rule and limiting our check to possible combinations of three digits. Scenario 1 Input: "61" Output: Yes Explanation: For the given input, the possible permutations of the digits are 16 and 61. Among ... Read More

Check if any large number is divisible by 19 or not in Python

Yaswanth Varma
Updated on 07-Aug-2025 13:10:58

418 Views

In mathematics, Divisibility helps us to determine whether a number can be divided by another without leaving a remainder. For example, 6 is divisible by 2 because 6/2 = 3 with no remainder. In this article, we are going to learn how to check if any large number is divisible by 19 or not in Python. Checking if any Large Number is Divisible by 19 Checking for the divisibility with small numbers can be easily handled by using the standard arithmetic operations. While dealing with the large numbers (contains 20, 30 or even 100 digits), the programming languages may run ... Read More

Check if any large number is divisible by 17 or not in Python

Arnab Chakraborty
Updated on 30-Dec-2020 13:01:12

702 Views

Suppose, we are given a number and we have to check whether the number is divisible by 17.So, if the input is like 99943, then the output will be Divisible.We will solve this problem using the repeated subtraction method, where we extract the last digit of the number and subtract it 5 times from the number until we get a two-digit number that is divisible by 17.To solve this, we will follow these steps −while number is divisible by 100, dolast_digit := number mod 10number := floor value of (number divided by 10)number := number - last_digit * 5return true ... Read More

Check if any interval completely overlaps the other in Python

Yaswanth Varma
Updated on 07-Aug-2025 12:59:50

2K+ Views

In many programming problems, Intervals are used to represent ranges such as time periods, numeric spans, etc. An interval is typically represented as a pair of numbers (start, end) where start

Check if any anagram of a string is palindrome or not in Python

Yaswanth Varma
Updated on 30-Jul-2025 18:50:48

492 Views

Check if any Anagram of a String is Palindrome An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. While palindrome is a word or phrase that reads the same forward and backward, like madam, racecar. In this article, we are going to check if any anagram of a string is a palindrome or not, i.e., we are not just checking whether the given string itself is a palindrome, but also whether it can ... Read More

Check if an integer can be expressed as a sum of two semi-primes in Python

Arnab Chakraborty
Updated on 30-Dec-2020 12:52:09

734 Views

Suppose we have a number n, we have to check whether n can be expressed as a sum of two semi-primes or not.As we know the semi-prime is a number if it can be expressed as product of two primes number. First few semi-prime numbers are (1 - 100 range): 4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95.So, if the input is like n = 108, then the output will be True as this ... Read More

Advertisements