You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This question needs redesigned as it enters the realm of "silly" when you can solve this in 1 line of code using first(predicate), none, any, find(predicate), etc. You'd have to list all functions they could not call to make them really want to recurse. If you want a recursive question, then force it with a custom data structure (NodeLinkedList) that doesn't have 10 existing methods that already do the same answer.
If you don't use a custom data structure, the silly factor is that people know they can just call:
return list.any { callback(it) }
Also, the existing Solution1 throws an exception on empty list. Probably not intended but also is not documented?
This question needs redesigned as it enters the realm of "silly" when you can solve this in 1 line of code using
first(predicate)
,none
,any
,find(predicate)
, etc. You'd have to list all functions they could not call to make them really want to recurse. If you want a recursive question, then force it with a custom data structure (NodeLinkedList) that doesn't have 10 existing methods that already do the same answer.If you don't use a custom data structure, the silly factor is that people know they can just call:
Also, the existing
Solution1
throws an exception on empty list. Probably not intended but also is not documented?the solution could be a little more efficient (don't copy the list, copy a view of the list instead):
Of course that assumes it isn't a LinkedList, but there is always:
The text was updated successfully, but these errors were encountered: