blakeembrey / code-problems

Common code and interview problems solved in multiple languages
MIT License
3.81k stars 509 forks source link

Array indexed exception for LongestCommonPrefix.java #158

Closed Akhilj786 closed 9 years ago

Akhilj786 commented 9 years ago

The assumption made while coding is: 1st string will be smallest but i believe that wont be the case. So we need to find the smallest string(in terms of length). I have done something similar here: https://github.com/Akhilj786/Algorithms/blob/master/src/DynamicProgram/LongestCommonPrefix.java#L11-L17

blakeembrey commented 9 years ago

You're absolutely right and this is probably a bug. You're welcome to submit a patch :+1:

blakeembrey commented 9 years ago

Actually, isn't this condition handling it? https://github.com/blakeembrey/code-problems/blob/master/solutions/java/LongestCommonPrefix.java#L13

Akhilj786 commented 9 years ago

:+1: