about | help | code help+videos | done | prefs |
Use a breadth first search to change all negatives to positives in the array. Start by adding the indices of all positive values to the queue. Then for each index, you can change its left and right neighbors to be positive and enqueue them. removeNegs([14, 20, -29, -10, -10, -28, 9, 12]) → [14, 20, 29, 10, 10, 28, 9, 12] removeNegs([2, -21, -2, 26]) → [2, 21, 2, 26] removeNegs([-2, -21, -2, 26]) → [2, 21, 2, 26] ...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: 300
Copyright Nick Parlante 2017 - privacy