Multi-way-merge

2 articles

dsa2 min read

Ugly Number II

Find the nth ugly number (only prime factors 2, 3, 5) using three pointers for the 2x, 3x, 5x merge streams.

Read →
dsa2 min read

Super Ugly Number

Find the nth super ugly number with prime factors only from a given list using K-pointer dynamic programming.

Read →