Timeline for Find the maximum number of consecutive zeros in an array
Current License: CC BY-SA 3.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 19, 2017 at 7:41 | history | protected | Jamal | ||
| May 15, 2014 at 6:49 | history | tweeted | twitter.com/#!/StackCodeReview/status/466832839590551553 | ||
| May 14, 2014 at 15:22 | comment | added | Anton Dozortsev | Hmm... Interesting task. If you know link source with similar task please give me it. Thanks | |
| May 13, 2014 at 23:38 | comment | added | phyrrus9 | The algorithm is actually quite identical to RLE (run length encoding) minus the output from it (RLE is usually *60, meaning 6 0's replace the "*60"). I would personally turn it into a method, and then be able to change the number you are taking into account. | |
| May 13, 2014 at 22:59 | answer | added | epergo | timeline score: 2 | |
| May 13, 2014 at 21:56 | comment | added | gnasher729 | Algorithm is absolutely fine. Quite straightforward, easy to see that it is correct, performance close to optimal. Unless you have evidence that its performance is critical, it can stay as it is. You'd probably want to turn the algorithm into a function for reuse. Looking at the comments above, you see how trying to optimise speed can lead to subtle problems if you don't watch out. | |
| May 13, 2014 at 15:17 | answer | added | Lesto | timeline score: 3 | |
| May 13, 2014 at 14:05 | history | edited | Jamal | CC BY-SA 3.0 |
added 29 characters in body
|
| May 13, 2014 at 10:14 | comment | added | tfinniga | You could put it right after tempLength++. It's probably fine where it is though. | |
| May 13, 2014 at 8:27 | answer | added | chillworld | timeline score: 6 | |
| May 13, 2014 at 8:15 | answer | added | PKopachevsky | timeline score: 3 | |
| May 13, 2014 at 8:07 | vote | accept | Gokul Nath KP | ||
| May 13, 2014 at 7:36 | comment | added | NPSF3000 | @Vogel612 True, and if you don't put another one after the loop you could miss the last length. | |
| May 13, 2014 at 7:11 | comment | added | Vogel612 | @NPSF3000 I think that would be rather premature optimization... It doesn't give much with a reasonable amount of Items and a good branch-prediction algorithm. | |
| May 13, 2014 at 7:08 | comment | added | NPSF3000 |
Suggestion, put if (tempLength > maxLength) { maxLength = tempLength; } in the else statement.
|
|
| May 13, 2014 at 6:56 | answer | added | Vogel612 | timeline score: 19 | |
| May 13, 2014 at 6:45 | history | asked | Gokul Nath KP | CC BY-SA 3.0 |