X1626: Sum elements after a negative in the array

Write the method int sumAfterNegative(int[] nums) in Java that returns the sum of the elements in the array nums after the first negative number.

Examples:

sumAfterNegative({-51,9,10}) -> 19
sumAfterNegative({51,-9,10}) -> 10
sumAfterNegative({-51,-9,-10}) -> -19
sumAfterNegative({51,9,10}) -> 0

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.