File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed
src/main/kotlin/g0001_0100
s0021_merge_two_sorted_lists
s0023_merge_k_sorted_lists
s0024_swap_nodes_in_pairs Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,19 @@ package g0001_0100.s0021_merge_two_sorted_lists
66
77import com_github_leetcode.ListNode
88
9+ /*
10+ * Example:
11+ * var li = ListNode(5)
12+ * var v = li.`val`
13+ * Definition for singly-linked list.
14+ * class ListNode(var `val`: Int) {
15+ * var next: ListNode? = null
16+ * }
17+ */
918class Solution {
10- fun mergeTwoLists (l1 : ListNode ? , l2 : ListNode ? ): ListNode ? {
11- var l1 = l1
12- var l2 = l2
19+ fun mergeTwoLists (list1 : ListNode ? , list2 : ListNode ? ): ListNode ? {
20+ var l1 = list1
21+ var l2 = list2
1322 var list: ListNode ? = ListNode (- 1 )
1423 val head = list
1524 while (l1 != null || l2 != null ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import com_github_leetcode.ListNode
77
88class Solution {
99 fun mergeKLists (lists : Array <ListNode >): ListNode ? {
10- return if (lists.size == 0 ) {
10+ return if (lists.isEmpty() ) {
1111 null
1212 } else mergeKLists(lists, 0 , lists.size)
1313 }
@@ -23,9 +23,9 @@ class Solution {
2323 }
2424 }
2525
26- private fun mergeTwoLists (left : ListNode ? , right : ListNode ? ): ListNode ? {
27- var left = left
28- var right = right
26+ private fun mergeTwoLists (leftLocal : ListNode ? , rightLocal : ListNode ? ): ListNode ? {
27+ var left = leftLocal
28+ var right = rightLocal
2929 if (left == null ) {
3030 return right
3131 }
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ class Solution {
1414 return reverse(head, len)
1515 }
1616
17- private fun getLength (curr : ListNode ): Int {
18- var curr: ListNode ? = curr
17+ private fun getLength (currLocal : ListNode ): Int {
18+ var curr: ListNode ? = currLocal
1919 var cnt = 0
2020 while (curr != null ) {
2121 cnt++
You can’t perform that action at this time.
0 commit comments