Java Solution: class Solution { public ListNode reverseList(ListNode head) { ListNode prev = null; while(head!=null) { ListNode next = head.next; head.next = prev; prev = head; head = next; } return prev; } }
@indiccoder4 ай бұрын
Python Solution: class Solution: def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: prev = None while head: next = head.next head.next = prev prev = head head = next return prev
@prasanthshan38884 ай бұрын
Bro 75 programs after
@indiccoder4 ай бұрын
@@prasanthshan3888 I'm planning to do a series on LeetCode Patterns such as two pointers, binary search etc. Also planning to start a series on machine learning.
@prasanthshan38884 ай бұрын
@@indiccoder bro Ai Ml start pannuka bro
@HeroHunter078 күн бұрын
@@indiccoder wow I'm eagerly waiting for leetcode patterns after this series thanks bro