Skip to content

Commit

Permalink
Return early
Browse files Browse the repository at this point in the history
  • Loading branch information
EFanZh committed Sep 25, 2024
1 parent ad7ac14 commit 6a5a658
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ impl Solution {
}

covered += right_end - right_start;
result = result.max(covered - right_end.saturating_sub(left_start + carpet_len));

let candidate = covered - right_end.saturating_sub(left_start + carpet_len);

if candidate == carpet_len {
return candidate as _;
}

result = result.max(candidate);
}

result as _
Expand Down

0 comments on commit 6a5a658

Please sign in to comment.