Amazon Interview Question

DS Coding questions one from strings and other from graphs