First of all, these two programs are written to solve the problem described in the following link: How do I optimize this algorithm so it doesn't exceed the given time l