AMD interview question

some dsa on linked list and dp