Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
My Favorite CS Puzzle – An Interactive Walkthrough | Better HN
My Favorite CS Puzzle – An Interactive Walkthrough
(opens in new tab)
(assaf.dev)
1 points
assafk
1y ago
2 comments
Share
2 comments
default
newest
oldest
Sianko
1y ago
I think the value of a repeated number can be found much easier: ``` long sum = 0; for (int i = 0; i < n; i++) { if(i < n - 1) { sum -= i; } sum += array[i]; }
printf("Element %d\r\n", sum); ```
assafk
OP
1y ago
This doesn't work if more than one value repeats itself.
j
/
k
navigate · click thread line to collapse