Time complexity of the solution to TextJustification seems to be O(n)?
DaiYue opened this issue · 1 comments
DaiYue commented
I'm wondering that the time complexity of this solution is O(n) rather than O(n^2) ? Seems that each letter is visited and output for just once.
Also I'm curious why the 2 functions _buildLine
and _buildSpecialLine
has a "_" prefix? Is it because they are private methods and this is some kind of a coding convention? Thanks a lot:)
soapyigu commented
You are right, i guess it is O(n). And the underline prefix is to follow my old java style from my earlier job - all private methods should be named with underline as prefix. I will fix it later, thank you.