File tree Expand file tree Collapse file tree 4 files changed +5
-60
lines changed Expand file tree Collapse file tree 4 files changed +5
-60
lines changed Original file line number Diff line number Diff line change 1- 3731-find-missing-elements python easy
2- 3732-maximum-product-of-three-elements-after-one-replacement python medium
3- 3733-minimum-time-to-complete-all-deliveries python medium
4- 3318-find-x-sum-of-all-k-long-subarrays-i python easy
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 44
55
66class Solution :
7- def pancakeSort (self , arr : List [int ]) -> List [int ]:
8-
9- def flip (sublist , k ):
10- i = 0
11- while i < k / 2 :
12- sublist [i ], sublist [k - i - 1 ] = sublist [k - i - 1 ], sublist [i ]
13- i += 1
7+ def pancakeSort (self , arr : List [int ]):
148 result = []
15- valueToSort = len (arr )
16- while valueToSort > 0 :
17- index = arr .index (valueToSort )
18- if index != valueToSort - 1 :
19- if index != 0 :
20- result .append (index + 1 )
21- flip (arr , index + 1 )
22- result .append (valueToSort )
23- flip (arr , valueToSort )
24- valueToSort -= 1
9+ for lastIdx in range (len (arr ), 1 , - 1 ):
10+ currIdx = arr .index (lastIdx )
11+ result .extend ([currIdx + 1 , lastIdx ])
12+ arr = arr [:currIdx :- 1 ] + arr [:currIdx ]
2513 return result
2614
2715
Original file line number Diff line number Diff line change @@ -115,23 +115,3 @@ It helps others discover the repo and keeps the project growing.
115115---
116116
117117Feedback / Questions → open an Issue or reach out on [ LinkedIn] ( https://www.linkedin.com/in/hogan-l/ )
118-
119- <!-- -LeetCode Topics Start-->
120- # LeetCode Topics
121- ## Array
122- | |
123- | ------- |
124- | [ 1009-pancake-sorting] ( https://github.com/hogan-tech/leetcode-solution/tree/master/1009-pancake-sorting ) |
125- ## Two Pointers
126- | |
127- | ------- |
128- | [ 1009-pancake-sorting] ( https://github.com/hogan-tech/leetcode-solution/tree/master/1009-pancake-sorting ) |
129- ## Greedy
130- | |
131- | ------- |
132- | [ 1009-pancake-sorting] ( https://github.com/hogan-tech/leetcode-solution/tree/master/1009-pancake-sorting ) |
133- ## Sorting
134- | |
135- | ------- |
136- | [ 1009-pancake-sorting] ( https://github.com/hogan-tech/leetcode-solution/tree/master/1009-pancake-sorting ) |
137- <!-- -LeetCode Topics End-->
You can’t perform that action at this time.
0 commit comments