After analysing the method declaration carefully I realized some bugs in the code:
1. the if condition on seeing min length as less than 0 returns out of memory error with a message that "required length is too large" which is contradictory to what we are checking in the condition. 2. We should actually return the out of memory error when it exceeds the SOFT_ARRAY_MAX_LENGTH 3. Moreover we are returning minLength in the third condition when we actually shouldn't because it exceeds the limit Kindly verify this.