반응형 Computer/Algorithm88 [LeetCode] 234. Palindrome Linked List - kotlin /** * Example: * var li = ListNode(5) * var v = li.`val` * Definition for singly-linked list. * class ListNode(var `val`: Int) { * var next: ListNode? = null * } */class Solution { fun isPalindrome(head: ListNode?): Boolean { if (head?.next == null) return true var prev: ListNode? = null var slow = head var fast = head while (fast != null && fast.next !=.. 2025. 3. 2. 이전 1 2 3 4 5 6 7 8 ··· 88 다음 반응형