-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第 161 题:用最精炼的代码实现数组非零非负最小值 index #582
Comments
const arr = [10, 21, 0, -7, 35, 7, 9, 23, 18]; arr.reduce((pre,cur,index)=>{ |
const ary = [10, 21, 0, -7, 35, 7, 9, 23, 18];
function getIndex(ary) {
const result = ary.reduce(
(acc, cur, index) =>
acc.value > cur && cur > 0 ? { value: cur, index } : acc,
{ value: Infinity, index: -1 }
);
return result.index;
} |
const arr = [10, 21, 0, -7, 35, 7, 9, 23, 18]; const min = arr..sort((a,b) => a-b).filter(n => n > 0)[0] |
这是来自QQ邮箱的假期自动回复邮件。 您好,您的邮件我已经收到,我会尽快给您回复,谢谢。
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: