Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Your code with first isn't "skipping the extra part on the first iteration", it does the exact opposite. See Ferdinand's answer for how to get it right. Commented Jul 5, 2024 at 22:29
  • In the "values are known to be distinct" case, how to you "check for the value of the last input"? Commented Jul 5, 2024 at 22:32
  • You "check for the value of the last input" by... checking... what the value is, and seeing if it is the value that you expect for the last input. I don't understand what needs explanation about it. Thanks for pointing out the logic error; clearly I didn't proofread that very well. Commented Jul 6, 2024 at 0:07
  • But how do you know what value to expect last? Wait, did you mean "input has a known "sentinel" value at the end, AND values are known to be distinct" (instead of "or")? Commented Jul 6, 2024 at 0:17
  • It was over a year ago, so I don't recall. Commented Jul 6, 2024 at 2:06