Given two integers N and X. The task is to print the absolute difference between the first X and last X digits in N. Considering the number of digits is atleast 2*x.
Input: N = 21546, X = 2 Output: 25 The first two digit in 21546 is 21. The last two digit in 21546 is 46. The absolute difference of 21 and 46 is 25. Input: N = 351684617, X = 3 Output: 266
- Store the last x digits of the number in last.
- Find the number of digits in the number.
- Remove all the digits except the first x.
- Store the first x integers of the number in first.
Below is the implementation of the above approach:
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1
- Minimize the absolute difference of sum of two subsets
- Minimum absolute difference between N and a power of 2
- Closest Palindrome Number (absolute difference Is min)
- Absolute difference between sum and product of roots of a quartic equation
- Check if array can be divided into two sub-arrays such that their absolute difference is K
- Minimum absolute difference of a number and its closest prime
- Largest subset where absolute difference of any two element is a power of 2
- Absolute Difference of all pairwise consecutive elements in an array
- Pair of prime numbers with a given sum and minimum absolute difference
- Difference between sums of odd and even digits
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.