Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half.
Given a ticket number n
, determine if it's lucky or not.
Example
- For
n = 1230
, the output should be
solution(n) = true
; - For
n = 239017
, the output should be
solution(n) = false
.
Input/Output
-
[execution time limit] 3 seconds (java)
-
[memory limit] 1 GB
-
[input] integer n
A ticket number represented as a positive integer with an even number of digits.
Guaranteed constraints:
10 ≤ n < 106
. -
[output] boolean
true
ifn
is a lucky ticket number,false
otherwise.
[Java] Syntax Tips
-
CodeSignalSolutions/Is_Lucky/Is_lucky.js
Lines 1 to 13 in 26a6634
-
CodeSignalSolutions/Is_Lucky/Is_lucky.java
Lines 13 to 22 in 26a6634