Just mark it. I can’t understand the solution of leetcode.
It is NP-hard problem. Bill Gates had a paper on this topic.
Problem
Java
LeetCode Solution
Approach 1: Sort Largest to Smallest
1 | class Solution { |
Submission Detail
- 215 / 215 test cases passed.
- Runtime: 6 ms, faster than 6.90% of Java online submissions for Pancake Sorting.
- Memory Usage: 42.8 MB, less than 5.26% of Java online submissions for Pancake Sorting.
Rosetta Code
To my surprise, the solution of Rosetta Code Sorting algorithms/Pancake sort can’t pass on leetcode.
1 | import java.util.ArrayList; |