搜索int阵列中的数字组,而无需使用循环
我有以下数组
int [] a = {4、5、5、5、4、3};
我想搜索阵列以获取平面序列, 并返回阵列中最长的扁平序列。
对于此数组,答案是3(5,6,5)
是否有没有使用循环的方法?
I have the following array
int[] a = { 4, 5, 6, 5, 4, 3 };
i would like to search the array for the flat sequences,
and return the longest flat sequence in the array.
for this array the answer would be 3 (5,6,5)
is there a way to do it without using a loop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从技术上讲,您可以使用递归,但这并不能真正摆脱循环。您只是不编写或 的关键字
Technically you can use recursion but that doesn't really gets rid of a loop. You just dont write the keyword
while
orfor