SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Originally posted by Rob Prime:
You should also check out the previous element (as stated in the problem description):
Please note that i > 0 check; without it the code fails if the first element is not 13.
Also, you shouldn't use break since that will abort the entire loop; any number afterwards is discarded.
Originally posted by Campbell Ritchie:
You shouldn't post that sort of thing when I am around because I am one of those people who believe you should only use break in a switch block. It ought to give the correct result with "continue," however.
Originally posted by Campbell Ritchie:
You're welcome. Let's see if it will work in old-fashioned "structured programming."
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Originally posted by Rob Prime:
You should also check out the previous element (as stated in the problem description):
Originally posted by LS chin:
Thank you. DeMorgan's law, eh? It's pretty challenging.
Edit: Wait, I think I got it!
if nums[i] == 13
nums[i - 1] == 13 // ----> is the array element that comes AFTER a 13, right?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank">Use Code Tags!!</a>
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank">Use Code Tags!!</a>
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank">Use Code Tags!!</a>
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|