solve problem 31
Optimize the code's time complexity to O(n^2).
add README.md file