Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[levenshtein][bug] Fix bug when # of changes exceeds max length of text #47

Merged
merged 1 commit into from
Apr 16, 2017

Conversation

jinatonic
Copy link
Contributor

Closes #46

@jinatonic jinatonic self-assigned this Apr 13, 2017
@jinatonic jinatonic requested a review from danh32 April 13, 2017 21:23
@jinatonic jinatonic assigned danh32 and unassigned jinatonic Apr 13, 2017
Copy link

@danh32 danh32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. good catch

if (i == 0) {
final List<Integer> resultList = new ArrayList<>(resultLength * 2);
int row = numRows - 1;
int col = numCols - 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the name chanes

final int[] result = new int[resultSize];
for (int i = 0; i < resultSize; i++) {
result[resultSize - 1 - i] = resultList.get(i);
}
return result;
Copy link

@danh32 danh32 Apr 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be painful to make this method's return type List<Int>? would avoid needing this conversion loop here and the quickreturn above could return Collections.emptyList()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point i'll just return them in list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh hm just realized that the above can't return empty list because it needs to return the number of columns with no modifications, and this iteration also adds the updates in reverse since we do reverse trace of the matrix to get the modifications. eh i'll just leave it for now lol.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jinatonic jinatonic merged commit 7323115 into master Apr 16, 2017
@jinatonic jinatonic deleted the fix_levenshtein branch April 17, 2017 17:16
@jinatonic jinatonic mentioned this pull request Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants