Тёмный

Leetcode - Odd Even Linked List (Python) 

Timothy H Chang
Подписаться 14 тыс.
Просмотров 6 тыс.
50% 1

May 2020 Leetcode Challenge
Leetcode - Odd Even Linked List

Опубликовано:

 

10 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 9   
@CodingWerkstatt
@CodingWerkstatt Год назад
I think this is even cleaner: def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]: if not head or not head.next or not head.next.next: return head odd = head even = head.next even_head = even while even and even.next: odd.next = odd.next.next even.next = even.next.next odd = odd.next even = even.next odd.next = even_head return head
@Mustafa-099
@Mustafa-099 Год назад
Whenever I am stuck with a problem, your content helps me out a lot Really enjoying it 🙂
@chinmaykulkarni201
@chinmaykulkarni201 3 года назад
Amazing! love your explanations :) Subscribed to your channel as well :)
@timc3406
@timc3406 3 года назад
Awesome, thank you!
@chenying7117
@chenying7117 Год назад
Thank you for the explanation! I follow your video while doing the question, it helps a lot!
@millionaire2023
@millionaire2023 3 месяца назад
class Solution: def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]: if not head or not head.next: return head oddptr = head evenptr = evenhead = head.next i = 1 while evenptr and evenptr.next: oddptr.next = evenptr.next oddptr = oddptr.next evenptr.next = oddptr.next evenptr = evenptr.next i += 2 oddptr.next = evenhead return head
@scullyy
@scullyy Год назад
Your first solution would have worked too, no? Splitting a linked list doesn't make it take up any more space
@user-mi9ll4rg3j
@user-mi9ll4rg3j Год назад
you need DS to store them which take up (n)
Далее
Leetcode - Maximum Sum Circular Subarray (Python)
14:58
Odd Even Linked List - 328. Leetcode Python
15:06
Просмотров 1,7 тыс.
Мой телеграмм: v1ann
00:14
Просмотров 45 тыс.
L6. Odd Even Linked List | Multiple Approaches
24:05
Просмотров 85 тыс.
Palindrome Linked List - Leetcode 234 - Python
11:06
Просмотров 94 тыс.
LeetCode was HARD until I Learned these 15 Patterns
13:00
So You've Been Rejected from FAANG
5:56
Просмотров 8 тыс.
Split Linked List in Parts - Leetcode 725 - Python
11:01
Rotate List - Linked List - Leetcode 61 - Python
10:16