ChapQ4.1

1. O(n^2) algorithm bug fixed
2. add efficient algorithm in O(n)
3. add one more test case