int (List<String> allNames) { int lengthSoFar = 0; int size = allNames.size(); for (int i = 0; i < size; i++) { lengthSoFar = (i > 0 ? lengthSoFar + 2 : 0) + allNames.get(i).length(); if (lengthSoFar > MAX_WARNING_SIZE) return i; } return size; }