Skip to content

LeetCode #143: Reorder List#140

Merged
WazedKhan merged 2 commits into
mainfrom
leetcode-143-reorder-list
Jul 2, 2026
Merged

LeetCode #143: Reorder List#140
WazedKhan merged 2 commits into
mainfrom
leetcode-143-reorder-list

Conversation

@WazedKhan

@WazedKhan WazedKhan commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added support for reordering a singly linked list in place for the “Reorder List” problem.
    • Included a simple linked-list helper for displaying node values, making it easier to verify results.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@WazedKhan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eaeb91d0-ce4f-4211-ad12-552990ff17a8

📥 Commits

Reviewing files that changed from the base of the PR and between e0c55fc and 591bf19.

📒 Files selected for processing (1)
  • LeetCode/medium/reorder_list_143.py
📝 Walkthrough

Walkthrough

A new LeetCode solution module is added for problem 143 (Reorder List), defining a ListNode class and a Solution class with print_linked_list and reorderList methods that reorder a singly linked list in-place.

Changes

Reorder List Implementation

Layer / File(s) Summary
Linked list node and reorder algorithm
LeetCode/medium/reorder_list_143.py
Defines ListNode, and Solution with print_linked_list and reorderList, which finds the list midpoint, reverses the second half, and merges both halves alternately in-place.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Estimated code review effort

1 (Trivial) | ~5 minutes

Suggested labels: enhancement, leetcode

Suggested reviewers: WazedKhan


🐰 A list once split, now woven tight,
Half reversed, half kept upright,
Nodes entwine in tidy pairs,
No more knots, no more scares,
Reordered clean, a rabbit's delight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the new LeetCode 143 reorder list implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leetcode-143-reorder-list

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@WazedKhan WazedKhan merged commit e153484 into main Jul 2, 2026
2 of 3 checks passed
@WazedKhan WazedKhan deleted the leetcode-143-reorder-list branch July 2, 2026 03:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@LeetCode/medium/reorder_list_143.py`:
- Around line 19-26: The reorderList method currently assumes head is non-null,
which causes a crash when called with an empty list. Update reorderList in the
Solution class to handle the None case up front before using slow.next, so the
fast/slow split logic only runs when head exists. Keep the existing midpoint
logic and next-pointer splitting intact after the early return.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 001a0d6e-970b-455c-8f74-d43ebdb19e5c

📥 Commits

Reviewing files that changed from the base of the PR and between 32d4ab4 and e0c55fc.

📒 Files selected for processing (1)
  • LeetCode/medium/reorder_list_143.py

Comment on lines +19 to +26
def reorderList(self, head: Optional[ListNode]) -> None:
slow, fast = head, head

while fast and fast.next:
slow = slow.next
fast = fast.next.next
half = slow.next
slow.next = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Crashes on empty list input.

If head is None, slow and fast both start as None; the while fast and fast.next loop is skipped, leaving slow as None. Line 25 then does slow.next, raising AttributeError: 'NoneType' object has no attribute 'next'.

🐛 Proposed fix
     def reorderList(self, head: Optional[ListNode]) -> None:
+        if not head or not head.next:
+            return
         slow, fast = head, head
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def reorderList(self, head: Optional[ListNode]) -> None:
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
half = slow.next
slow.next = None
def reorderList(self, head: Optional[ListNode]) -> None:
if not head or not head.next:
return
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
half = slow.next
slow.next = None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@LeetCode/medium/reorder_list_143.py` around lines 19 - 26, The reorderList
method currently assumes head is non-null, which causes a crash when called with
an empty list. Update reorderList in the Solution class to handle the None case
up front before using slow.next, so the fast/slow split logic only runs when
head exists. Keep the existing midpoint logic and next-pointer splitting intact
after the early return.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant