Pancake Sort #145
Replies: 1 comment
-
Pancake Sort Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array arr. input: arr = [1, 5, 4, 3, 2] output: [1, 2, 3, 4, 5] # to clarify, this is pancakeSort's output Note: it’s called pancake sort because it resembles sorting pancakes on a plate with a spatula, where you can only use the spatula to flip some of the top pancakes in the plate. To read more about the problem, see the Pancake Sorting Wikipedia page. Constraints: [time limit] 5000ms [input] array.integer arr [input] integer k 0 ≤ k |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions