From 112b3b756fae84e217fd3b6a7cff39f6d01696ec Mon Sep 17 00:00:00 2001 From: Kagura Date: Fri, 17 May 2024 21:06:09 +0800 Subject: [PATCH] Stage --- src/Main.kt | 5 +---- src/Test160.kt | 23 +++++++++++++++++++++++ src/Test283.kt | 37 +++++++++++++++++++++++++++++++++++++ src/Test3.kt | 3 --- src/Test49.kt | 12 ++++++++++++ 5 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 src/Test160.kt create mode 100644 src/Test283.kt create mode 100644 src/Test49.kt diff --git a/src/Main.kt b/src/Main.kt index 911c4b0..e3303b5 100644 --- a/src/Main.kt +++ b/src/Main.kt @@ -1,7 +1,4 @@ - - - fun main() { - val t = Test3() + val t = Test283() t.test() } \ No newline at end of file diff --git a/src/Test160.kt b/src/Test160.kt new file mode 100644 index 0000000..ea4a63c --- /dev/null +++ b/src/Test160.kt @@ -0,0 +1,23 @@ +class Test160 { + class ListNode(var `val`: Int) { + var next: ListNode? = null + } + + fun getIntersectionNode(headA: ListNode?, headB: ListNode?): ListNode? { + if (headA==null||headB==null){ + return null + } + var hA = headA + while (hA!=null){ + var hB = headB + while (hB!=null){ + if (hA==hB){ + return hB + } + hB = hB.next + } + hA = hA.next + } + return null + } +} \ No newline at end of file diff --git a/src/Test283.kt b/src/Test283.kt new file mode 100644 index 0000000..d5fc5c3 --- /dev/null +++ b/src/Test283.kt @@ -0,0 +1,37 @@ +class Test283 { + fun moveZeroes(nums: IntArray): Unit { + val size = nums.size; + if (size==1) { + return + } + var i = 0; + while (i < size-1){ + if (nums[i]==0){ + var j = i+1 + while ( j < size && nums[j]==0 ){ + j++ + } + if (j==size){ + return + } + nums[i] = nums[j] + nums[j] = 0 + } + i++ + } + } + + fun test(){ + val array = intArrayOf(0,1,0,3,12) + for (i in array){ + print(i) + print(",") + } + print("\n") + moveZeroes(array) + for (j in array){ + print(j) + print(",") + } + } +} \ No newline at end of file diff --git a/src/Test3.kt b/src/Test3.kt index 059a601..c84668f 100644 --- a/src/Test3.kt +++ b/src/Test3.kt @@ -1,8 +1,5 @@ class Test3 { - fun lengthOfLongestSubstring(s: String): Int { - - } fun test(){ diff --git a/src/Test49.kt b/src/Test49.kt new file mode 100644 index 0000000..ea5ec6a --- /dev/null +++ b/src/Test49.kt @@ -0,0 +1,12 @@ +class Test49 { + + + + fun groupAnagrams(strs: Array): List> { + var map = HashMap() // Index Identifier + + + } + + +} \ No newline at end of file