LeetCode
枫叶千言
这个作者很懒,什么都没留下…
展开
-
1. 反转链表
1. 206. 反转链表 https://leetcode-cn.com/problems/reverse-linked-list/ https://leetcode-cn.com/problems/reverse-linked-list/ /** * Definition for singly-linked list. * type ListNode struct { * ...原创 2019-08-15 17:21:53 · 80 阅读 · 0 评论 -
2. 两两交换链表中的节点
1.24. 两两交换链表中的节点 https://leetcode-cn.com/problems/swap-nodes-in-pairs/ https://leetcode-cn.com/problems/swap-nodes-in-pairs/ /** * Definition for singly-linked list. * type ListNode struct { * ...原创 2019-08-15 17:24:27 · 92 阅读 · 0 评论 -
3. 环形链表
1.141. 环形链表 https://leetcode-cn.com/problems/linked-list-cycle/ https://leetcode-cn.com/problems/linked-list-cycle/submissions/ /** * Definition for singly-linked list. * type ListNode struct { ...原创 2019-08-15 17:27:33 · 94 阅读 · 0 评论 -
4. 环形链表2
1.142. 环形链表2 https://leetcode-cn.com/problems/linked-list-cycle-ii/ https://leetcode-cn.com/problems/linked-list-cycle-ii/ /** * Definition for singly-linked list. * type ListNode struct { *...原创 2019-08-15 17:28:58 · 87 阅读 · 0 评论 -
5. K 个一组翻转链表
1.25. K 个一组翻转链表 https://leetcode-cn.com/problems/reverse-nodes-in-k-group/ https://leetcode-cn.com/problems/reverse-nodes-in-k-group/ /** * Definition for singly-linked list. * type ListNode st...原创 2019-08-15 17:31:16 · 214 阅读 · 0 评论 -
6. 有效的括号
1. 题目: 有效的括号 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 注意空字符串可被认为是有效字符串。 示例 1: 输入: "()" 输出: true 示例 2: 输入: "()[]{}" 输出: true 示例 3: 输入: "(]" 输...原创 2019-09-28 16:07:37 · 137 阅读 · 0 评论 -
7.用队列实现栈&用栈实现队列
1.232. 用栈实现队列 使用栈实现队列的下列操作: push(x) -- 将一个元素放入队列的尾部。 pop() -- 从队列首部移除元素。 peek() -- 返回队列首部的元素。 empty() -- 返回队列是否为空。 示例: MyQueue queue = new MyQueue(); queue.push(1); queue.push(2); queue.peek();...原创 2019-09-28 16:15:20 · 414 阅读 · 0 评论 -
8.返回数据流中的第K大元素
1. 703返回数据流中的第K大元素 设计一个找到数据流中第K大元素的类(class)。注意是排序后的第K大元素,不是第K个不同的元素。 你的 KthLargest 类需要一个同时接收整数 k 和整数数组nums 的构造器,它包含数据流中的初始元素。每次调用 KthLargest.add,返回当前数据流中第K大的元素。 示例: int k = 3; int[] arr = [4,5,8,2...原创 2019-09-28 16:16:44 · 319 阅读 · 0 评论 -
9.返回滑动窗口中的最大值
1. 239滑动窗口最大值 给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 返回滑动窗口中的最大值。 示例: 输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3 输出: [3,3,5,5,6,7] 解释: 滑动窗口的位置 最大值 -------...原创 2019-09-28 16:19:30 · 362 阅读 · 0 评论