![]() |
Given a positive integer N, the task is to maximize the integer N by rearranging the digits and check if the sum of the left half digits is divisible by the sum of the right half digits or not. If found to be true, then print “Yes”. Otherwise, print “No”.
Examples:
Approach: The given problem can be solved by sorting the given digits of the number N in descending order maximizing the value of N and then checking for the divisibility of the sum of the left and the right half digits. Follow the steps below to solve the problem:
Below is the implementation of the above approach: C++
Java
Python3
C#
Javascript
Output:
Yes
Time Complexity: O(log10N) |
Reffered: https://www.geeksforgeeks.org
Mathematical |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |