Blog•Apr 9, 2026
Java Interview Question - Detecting Duplicate Product Titles
A junior developer built a Spring Boot service that groups e‑commerce product titles by sorting words and comparing each pair, resulting in O(n²·k log k) time. The implementation repeatedly re‑sorts identical titles and uses a visited array to avoid duplicate work. A more efficient approach creates a canonical signature for each title—lower‑casing, splitting, sorting, and joining words—then stores titles in a HashMap keyed by that signature, achieving O(n·k log k) time and linear space. The article also discusses handling punctuation and stopwords during normalization.