id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

apr_9_2019_APSLHL_sumPositiveModified


Write a method that returns the sum of all the positive numbers in an array of integers, except do not include a positive number if it has a negative number immediately before and after it. So do NOT include the negative numbers in the sum but also do NOT include positive numbers that are surrounded by negative numbers. You may not use any functional programming.


apr_9_2019_APSLHL_sumPositiveModified([]) → 0
apr_9_2019_APSLHL_sumPositiveModified([5, 2, 1]) → 8
apr_9_2019_APSLHL_sumPositiveModified([214, 325, -5478, 953, -346, 54369, -436, 865, -532, 967, -436]) → 539

...Save, Compile, Run (ctrl-enter)

public int apr_9_2019_APSLHL_sumPositiveModified(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy