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

205 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

954 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

Java program to shift array elements to the left

Alshifa Hasnain
Updated on 07-Aug-2025 18:19:53

1K+ Views

What Is Left Shifting in an Array? Shifting the array elements to the left by the given number of positions is also known as left rotation of the array. The element at the beginning gets pushed out of the front during the shift, but instead of being deleted, they are re-attached at the end of the array. Let us consider an example for a better understanding: Original Array: After 1 Left Shift: We can see in the above figure that, after the first shift, the element "1" is pushed out and then reattached at the end of the ... Read More

Java program to shuffle an array using list

Alshifa Hasnain
Updated on 07-Aug-2025 17:33:30

275 Views

In this article, we will learn how to shuffle an array using a list in Java. To do so, we will be using: Using Collections.shuffle() Method Using Fisher-Yates shuffle Using Java Streams Using Collections.shuffle() Method Shuffling an array means randomly rearranging its elements. The Java Collections framework provides the Collections.shuffle() Method, which shuffles a list. Since this method shuffles the list randomly, the order of the resultant elements is different each time we use it. Example Following is the program to shuffle an array using a ... Read More

Find total number of distinct years from a string in C++ Program

Aman Kumar
Updated on 07-Aug-2025 16:06:02

724 Views

In this article, we will write a C++ program to find the total number of distinct years from a string. Here, we have a string that contains the words and the dates. Our task is to find the number of distinct years mentioned. Let's see the following example scenario to understand the problem better: Scenario 1 Input: str = "The Berlin Wall fell on 09/11/1989. The first website was launched on 06/08/1991." Output: Total number of distinct years: 2 Explanation: Two distinct years are referenced: 1989, and 1991 Scenario 2 Input: str = "TutorialsPoint India was founded on ... Read More

Find the node with minimum value in a Binary Search Tree in C++

Farhan Muhamed
Updated on 07-Aug-2025 16:00:04

3K+ Views

In this article, we will explain how to find the node with the minimum value in a binary search tree (BST) and provide a C++ implementation. A binary search tree is a data structure that stores data in a sorted order such that for every node, the left subtree contains values less than the node's value, and the right subtree contains values greater than the node's value. Find Minimum Value in a Binary Search Tree Given the root node of a binary search tree, the task is to find the node with the minimum value in the tree. The ... 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

420 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 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

Adding two polynomials using Linked List in C++.

Manisha Chand
Updated on 06-Aug-2025 19:24:24

27K+ Views

Adding two Polynomials using a Linked List in C++ Linked list is a data structure that stores each element as an object in a node of the list. Every node contains two parts data node and links to the next node. A polynomial is a mathematical expression that consists of variables and coefficients. For example, x^2 - 4x + 7. In the Polynomial linked list, the coefficients and exponents of the polynomial are defined as the data node of the list. For example, if the given Polynomial equation is: 4x7 + 12x2 + 45. Its representation in a linked list looks like: ... Read More

Binary Search a String in C++

Ravi Ranjan
Updated on 06-Aug-2025 19:01:28

4K+ Views

The binary search algorithm works on the divide-and-conquer principle as it keeps dividing the array in half before searching. To search for an element in an array using binary search, it should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left or right sub-array or return the middle element. In this article, we are given a sorted array of strings, and our task is to search for the given string using a binary search algorithm. ... Read More

Advertisements