Implement hirshberg lcs algorithm