#
Git
Press
robotliu
Login
Collections
/
leetcode
leetcode
Collection Posts
2022/04/29
1144.Decrease Elements To Make Array Zigzag
Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.An array A is a zigzag array if either:Return the minimum number of moves to transform the given array nums into a zigzag array.
2022/04/29
[121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
class Solution:def maxProfit(self, prices: List[int]) -> int:length = len(prices)
2022/04/29
[912_Sort an Array](<https://leetcode.com/problems/sort-an-array/>)
Given an array of integers nums, sort the array in ascending order.Example 1:Input: [5,2,3,1]
2022/04/29
leetcode_summary
<!-- wp:table {"backgroundColor":"subtle-pale-green","align":"center","className":"is-style-stripes"} --> <table class="wp-block-table aligncenter has-subtle-pale-green-background-color has-background is-style-stripes"><tbody><tr><td> <a href="https://leetcode.com/">L</a><a href="https://leetcode.com/problemset/all/" target="_blank" rel="noreferrer noopener" aria-label="(在新窗口打开)">eetCode - The World's Leading Online Programming Learning Platform </a></td></tr><tr><td> <a href="onenote:Data_str
2022/04/29
冒泡排序
冒泡排序(Bubble Sort)也是一种简单直观的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢"浮"到数列的顶端。作为最简单的排序算法之一,冒泡排序给我的感觉就像 Abandon 在单词书里出现的感觉一样,每次都在第一页第一位,所以最熟悉。冒泡排序还有一种优化算法,就是立一个 flag,当在一趟序列遍历中元素没有发生交换,则证明该序列已经有序。但这种改进对于提升性能来说并没有什么太大作用。