问题陈述:
Given an array of ints, compute if the array contains somewhere a value followed in the array by that value times 10. We'll use the convention of considering only the part of the array that begins at the given index.The initial call will pass in index as 0.
示例:
公共(public) boolean 数组220(int[] nums,int索引)
array220({1, 2, 20}, 0) → true
array220({3, 30}, 0) → true
array220({3}, 0) → false**
我陷入了这个问题,没有办法解决它。
最佳答案
for (int i = index; i < nums.length - 1; i++)
if (nums[i] * 10 == nums[i + 1]) return true;
return false;
关于java - 请帮我解决关于数组的 Java 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5502927/