refactor variable L to lengthOfInputArray