fix bug, calculate the short string

fix bug #2 test case failed, should consider the head + tail energy to
maximize longest sub string.