about | help | code help+videos | done | prefs |
Given a queue of integers, reorder the queue so that all of the even integers come before all of the odd integers. The even numbers should remain in their original order, and the odd numbers should remain in their original order. Use one auxiliary queue to solve this problem. (Hint: Put all odds into the auxiliary queue and move them back in). Start your code with: Queue<Integer> queue1 = new LinkedList<Integer>(list); Queue<Integer> queue2 = new LinkedList<Integer>(); queue_evensBeforeOdds([1, 2, 3, 4, 5, 6]) → [2, 4, 6, 1, 3, 5] queue_evensBeforeOdds([1, 2, 3]) → [2, 1, 3] queue_evensBeforeOdds([1, 1, 2, 2, 3, 3, 4, 4]) → [2, 2, 4, 4, 1, 1, 3, 3] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy