Skip to content

Daily: 2026-10-19 — Merge Sorted Array - #7

Merged
GAjay merged 2 commits into
mainfrom
daily/2026-10-19-merge-sorted-array
Oct 21, 2026
Merged

GAjay merged 2 commits into
mainfrom
daily/2026-10-19-merge-sorted-array

Conversation

@cursor

@cursor cursor Bot commented Oct 19, 2026

Copy link
Copy Markdown

Problem

  • Slug: merge-sorted-array
  • Folder: problems/2026-10-19-merge-sorted-array/

Approach

Merge from the end of nums1 using three pointers (i on the last real element of nums1, j on the last element of nums2, k on the write position). At each step, place the larger of the two tails into nums1[k] and move the corresponding pointer. This avoids overwriting unmerged values in nums1 and runs in O(m + n) time with O(1) extra space.

Tests

node --test problems/2026-10-19-merge-sorted-array/merge-sorted-array.test.js
npm run test:ci

Both commands passed locally.

Open in Web View Automation 

@GAjay
GAjay marked this pull request as ready for review October 21, 2026 04:58
@GAjay
GAjay merged commit a827f21 into main Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant