Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions seungjae-choi/pg_분수의 덧셈.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution {
fun solution(numer1: Int, denom1: Int, numer2: Int, denom2: Int): IntArray {
var finalDenom = denom1 * denom2
var finalNumer = numer1 * denom2 + numer2 * denom1
val finalGcd = gcd(finalNumer, finalDenom)
return intArrayOf(finalNumer/finalGcd, finalDenom/finalGcd)
}
private fun gcd(a: Int, b:Int): Int = if (b != 0) gcd(b, a % b) else a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음수가 들어올 경우도 있으니 abs() 같은 절댓값 활용해도 좋을 것 같아요! !

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

노션 내에 있는 EOL 관련 아티클 한번 읽어보시면 좋을 것 같아요 !!

요약해서 말씀드리면 EndOfLine이라는 한 줄의 끝을 남기는 것이에요!