Kotlin
kotlin 풀이
테스트코드
package leetcode
import org.junit.Test
import org.assertj.core.api.Assertions.assertThat
class PS1TwoSum {
@Test
fun test() {
val solution = Solution()
assertThat(solution.twoSum(intArrayOf(2,7,11,15), 9)).contains(0).contains(1)
assertThat(solution.twoSum(intArrayOf(3, 2, 4), 6)).contains(1).contains(2)
assertThat(solution.twoSum(intArrayOf(3, 3), 6)).contains(0).contains(1)
assertThat(solution.twoSum(intArrayOf(2, 5, 5, 11), 10)).contains(1).contains(2)
}
}풀이
hashmap 이용
220 ms, 85.89%
Last updated
Was this helpful?