rewrite leetcode word ladders i ii