algorithm notes: leetcode#667 beautiful arrangement 2