I implements my recursive version easily, but can't figure out when it turns out exceed time limit, so I changed to iterate version, maybe cost 1 hour