diff --git a/src/Test80.kt b/src/Test80.kt new file mode 100644 index 0000000..2fdc074 --- /dev/null +++ b/src/Test80.kt @@ -0,0 +1,23 @@ +class Test80 { + class Solution { + fun removeDuplicates(nums: IntArray): Int { + if (nums.size <= 2){ + return nums.size + } + + var slow = 1 + + for (fast in 2.. nums.lastIndex){ + if (nums[fast] != nums[slow] || nums[slow] != nums[slow-1]) { + nums[++slow] = nums[fast] + } + } + return slow +1 + } + } + + fun test(){ + println(Solution().removeDuplicates(intArrayOf(0,0,1,1,1,1,2,3,3))) + } + +} \ No newline at end of file