This commit is contained in:
Kagura 2024-05-17 21:06:09 +08:00
parent 17b6c6e9a4
commit 112b3b756f
5 changed files with 73 additions and 7 deletions

View file

@ -1,7 +1,4 @@
fun main() {
val t = Test3()
val t = Test283()
t.test()
}

23
src/Test160.kt Normal file
View file

@ -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
}
}

37
src/Test283.kt Normal file
View file

@ -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(",")
}
}
}

View file

@ -1,8 +1,5 @@
class Test3 {
fun lengthOfLongestSubstring(s: String): Int {
}
fun test(){

12
src/Test49.kt Normal file
View file

@ -0,0 +1,12 @@
class Test49 {
fun groupAnagrams(strs: Array<String>): List<List<String>> {
var map = HashMap<Int,Int>() // Index Identifier
}
}