Want to know:
同时记录max和min,然后可以这样避免负数 int min = nums[0], max = nums[0];int res = nums[0];for (int i = 1; i < nums.length; i++) {if (nums[i] >= 0) {max = Math.max(nums[i], max * nums[i]);min = Math.min(nums[i], min * nums[i]);} else if (nums[i] < 0) {int oldMax = max;max = Math.max(nums[i], min * nums[i]);min = Math.min(nums[i], oldMax * nums[i]);}res = Math.max(res, max);}return res;
Get a detailed, AI-powered explanation for this question and thousands more on StudyFetch.
Get the Answer for FreeHow StudyFetch Helps You Master This Topic
AI-Powered Answers
Get instant, detailed explanations powered by AI that understands your course material.
Deep Understanding
Go beyond surface-level answers with step-by-step breakdowns and examples.
Personalized Learning
Sparky adapts to your learning style and helps you connect ideas.
Practice & Test
Turn any question into flashcards, quizzes, and practice tests to solidify your knowledge.
Explore More Questions
- _________ is a constraint requiring that two binary variables be equal and that thus are both either in or out of the solution together. a. Conditional constraint b. Corequisite constraint c. k out of n alternatives constraint d. Mutually exclusive constraint
- Choose examples of tasks:A. Prompt the customer to enter an account number.B. Validate the account number with your customer data.C. Configure hold music while you perform the process in the back-end.D. Fetch customer details such as account balance, credit card due date, and appointment history.E. Using audio, share the requested information with the customer.F. Configure simple account number validation.G. End the task sequence with an action that tells the flow where to go next.H. All choices before
- Corneille fait transparaître la vie de qui a travers cela ?