Created
July 15, 2019 15:12
-
-
Save cg4jins/d2728181d23e1e6d70bd6f00726815f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
fun solution(a: Int, b: Int): Long { | |
var answer = 0L | |
if (a == b){ | |
return a.toLong() | |
} | |
var min = Integer.min(a,b) | |
var max = Integer.max(a,b) | |
for (i in min .. max){ | |
answer += i | |
} | |
return answer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment