摘要:
题目链接:https://leetcode.com/problems/reverse-words-in-a-string/反转字符串的方法有很多种。要求空间复杂度是常数的话,可以先反转所有的单词,然后反转整个字符串。例如"the sky is blue",可以先反转为"eht yks si eulb... 阅读全文
摘要:
题目链接:https://leetcode.com/problems/majority-element/官方的Solution:Runtime: O(n2) — Brute force solution: Check each element if it is the majority elemen... 阅读全文
摘要:
题目链接:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/当 k ≥ prices.size()/ 2 时:题目等价于 k 无限大的情形。当 k < prices.size()/ 2 时:用dp[m][n+1]表示在[... 阅读全文