about | help | code help+videos | done | prefs |
Write a method that adds the corresponding elements of two arrays (nums1 and nums2) and returns the resulting array. However, if either of the elements is a zero in a particular position, then that position in the resulting array should be a zero. As a precondition, you may assume the two input parameter arrays will be the same length. Look at the test data for examples. Oct11_2019_SLHL_sumUnlessZero([4, 7, 0, -2, 0, 8], [1, 0, 5, 8, 3, 0]) → [5, 0, 0, 6, 0, 0] Oct11_2019_SLHL_sumUnlessZero([1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1]) → [8, 8, 8, 8, 8, 8, 8] Oct11_2019_SLHL_sumUnlessZero([5, 0, 7, 0, 123, 0, 3, 0, 23, 0, 77], [0, 4, 0, 82, 0, 31, 0, 43, 0, 63, 0]) → [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 320
Copyright Nick Parlante 2017 - privacy