leetcode 题解 84. Largest Rectangle in Histogram (单调栈的应用们) Given n non-negative integers representing the histog…
标签:LeetCode
Swift 将有序数组转换为二叉搜索树 - LeetCode
LeetCode 题目: 将有序数组转换为二叉搜索树 将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。 本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。 例如: 给…
Swift 数数并说 - LeetCode
LeetCode.jpg 题目:数数并说 描述:报数序列是指一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 被读作 …
804. Unique Morse Code Words
题目网址:https://leetcode.com/problems/unique-morse-code-words/description/ 大意:求一个数组里面的字母所翻译的摩尔斯电码具体有多少种(难道莫尔斯电码的重…
LeetCode 344.反转字符串
题目描述 编写一个函数,其作用是将输入的字符串反转过来。 示例 1: 输入: "hello" 输出: "olleh" 示例 2: 输入: "A man, a plan, a canal: Panama" 输出: "ama…
Swift 两个数组的交集 II - LeetCode
两个数组的交集 II 给定两个数组,写一个方法来计算它们的交集。 例如: 给定 nums1 = [1, 2, 2, 1], nums2 = [2, 2], 返回 [2, 2]. 注意: 输出结果中每个元素出现的次数,应与…
[LeetCode][Search] 339. Nested List Weight Sum
Problem More LeetCode Discussions Given a nested list of integers, return the sum of all integers in the list …
3. 链表求环
已知链表中可能存在环,若有环返回环起始节点,否则返回NULL。 如图: 方法一:使用set求环起始节点 遍历链表,将链表中节点对应的指针(地址)插入set中; 在遍历时插入节点前,需要在set中查找,第一个在set中发现…
Swift 加一 - LeetCode
题目:加一 描述: 给定一个非负整数组成的非空数组,给整数加一。 可以假设整数不包含任何前导零,除了数字0本身。 最高位数字存放在列表的首位。 语文能力捉急啊,看了半天没看懂。。。然后去找了英文原题(我实在LeetCod…
算法相关文章索引(1)
基本常识 时间复杂度百度百科 空间复杂度百度百科 空间复杂度是O(1)是什么意思 O(1)指额外空间相对于输入数据量来说是常数 中位数百度百科 常见OJ评判结果对照表,作为ACMer你懂得! 什么是极小化极大算法? Mi…
Swift 3的幂 - LeetCode
LeetCode 题目: 3的幂 描述:给定一个整数,写一个函数来判断它是否是 3 的幂次方。 案例1: 输入: 27 输出: true 示例 2: 输入: 0 输出: false 案例 3: 输入: 9 输出: tru…
LeetCode #771.Jewels and Stones python
Question You’re given strings J representing the types of stones that are jewels, and S representing the…