From 4127dac8ad8082d4e421ac4ab41f5e9d0ecccedd Mon Sep 17 00:00:00 2001 From: ichroman Date: Tue, 15 Oct 2019 08:16:56 +0700 Subject: [PATCH 1/2] add Solution.kt --- #442/kotlin/Solution.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 #442/kotlin/Solution.kt diff --git a/#442/kotlin/Solution.kt b/#442/kotlin/Solution.kt new file mode 100644 index 0000000..cdf7ecd --- /dev/null +++ b/#442/kotlin/Solution.kt @@ -0,0 +1,14 @@ +class Solution { + fun findDuplicates(nums: IntArray): List { + val result: MutableList = ArrayList() + val temp: MutableList = ArrayList() + for (i in nums) { + if (temp.contains(i)) { + result.add(i) + } else { + temp.add(i) + } + } + return result + } +} From 9704ac5609092de7d0719fe85544254c1f25dbb7 Mon Sep 17 00:00:00 2001 From: ichroman Date: Wed, 16 Oct 2019 09:59:57 +0700 Subject: [PATCH 2/2] add comment --- #442/kotlin/Solution.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/#442/kotlin/Solution.kt b/#442/kotlin/Solution.kt index cdf7ecd..f80235d 100644 --- a/#442/kotlin/Solution.kt +++ b/#442/kotlin/Solution.kt @@ -1,3 +1,7 @@ +/** + * https://leetcode.com/problems/find-all-duplicates-in-an-array/ + */ + class Solution { fun findDuplicates(nums: IntArray): List { val result: MutableList = ArrayList()