#Find if array has value '1' using recursion
10 messages · Page 1 of 1 (latest)
Hey, @half osprey!
Please remember to /close this post once your question has been answered!
you need to put int to your method parameter
so your recursion will work
and must it be recursion?
@blazing bramble yes it must be recursion and also it should not have no parameter
@blazing bramble but I can use helper method though I don't know where I should implement it
then put to your method paremeter, which will represent the "1" number found
I'd suggest to add an index parameter ('what element of the array am I currently looking at?')
Then you can reduce your problem to three cases:
- if index has surpassed the array length: return false
- if element at index is 2: return true
- otherwise: increase index by one and call the method again (passing the now increased index as the argument)
Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.