Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Feb 6, 2024 · Fundamentals

How to Merge Two Sorted Arrays In‑Place Without Extra Space

This article walks through the classic interview problem of merging two non‑decreasing integer arrays directly into the first array, compares a naïve extra‑array solution with an optimal in‑place two‑pointer algorithm, and provides full Java implementations.

Javaarray mergingin-place algorithm
0 likes · 7 min read
How to Merge Two Sorted Arrays In‑Place Without Extra Space
FunTester
FunTester
Mar 21, 2020 · Fundamentals

How to Find Duplicate Numbers in an Array in O(n) Time and O(1) Space

This article explains two algorithmic solutions for locating any duplicate number in an array of length n where values range from 0 to n‑1: a straightforward HashSet method using O(n) extra space and an in‑place swapping technique that achieves O(1) space, complete with Java and JavaScript code examples and complexity analysis.

ArrayJavaJavaScript
0 likes · 5 min read
How to Find Duplicate Numbers in an Array in O(n) Time and O(1) Space