I am ne zha / Jeskson

Results 398 issues of I am ne zha / Jeskson

# [200\. 岛屿数量](https://leetcode.cn/problems/number-of-islands/) ## Description Difficulty: **中等** Related Topics: [深度优先搜索](https://leetcode.cn/tag/depth-first-search/), [广度优先搜索](https://leetcode.cn/tag/breadth-first-search/), [并查集](https://leetcode.cn/tag/union-find/), [数组](https://leetcode.cn/tag/array/), [矩阵](https://leetcode.cn/tag/matrix/) 给你一个由 `'1'`(陆地)和 `'0'`(水)组成的的二维网格,请你计算网格中岛屿的数量。 岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。 此外,你可以假设该网格的四条边均被水包围。 **示例 1:** ``` 输入:grid = [ ["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0","0","0"], ["0","0","0","0","0"] ]...

# [198\. 打家劫舍](https://leetcode.cn/problems/house-robber/) ## Description Difficulty: **中等** Related Topics: [数组](https://leetcode.cn/tag/array/), [动态规划](https://leetcode.cn/tag/dynamic-programming/) 你是一个专业的小偷,计划偷窃沿街的房屋。每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,**如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警**。 给定一个代表每个房屋存放金额的非负整数数组,计算你 **不触动警报装置的情况下** ,一夜之内能够偷窃到的最高金额。 **示例 1:** ``` 输入:[1,2,3,1] 输出:4 解释:偷窃 1 号房屋 (金额 = 1) ,然后偷窃 3 号房屋 (金额...

# [169\. 多数元素](https://leetcode.cn/problems/majority-element/) ## Description Difficulty: **简单** Related Topics: [数组](https://leetcode.cn/tag/array/), [哈希表](https://leetcode.cn/tag/hash-table/), [分治](https://leetcode.cn/tag/divide-and-conquer/), [计数](https://leetcode.cn/tag/counting/), [排序](https://leetcode.cn/tag/sorting/) 给定一个大小为 `n`的数组 `nums` ,返回其中的多数元素。多数元素是指在数组中出现次数 **大于** `⌊ n/2 ⌋` 的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 **示例 1:** ``` 输入:nums = [3,2,3]...

# [160\. 相交链表](https://leetcode.cn/problems/intersection-of-two-linked-lists/) ## Description Difficulty: **简单** Related Topics: [哈希表](https://leetcode.cn/tag/hash-table/), [链表](https://leetcode.cn/tag/linked-list/), [双指针](https://leetcode.cn/tag/two-pointers/) 给你两个单链表的头节点 `headA` 和 `headB` ,请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点,返回 `null` 。 图示两个链表在节点 `c1` 开始相交**:** 题目数据 **保证** 整个链式结构中不存在环。 **注意**,函数返回结果后,链表必须 **保持其原始结构** 。 **自定义评测:** **评测系统**...

# [155\. 最小栈](https://leetcode.cn/problems/min-stack/) ## Description Difficulty: **中等** Related Topics: [栈](https://leetcode.cn/tag/stack/), [设计](https://leetcode.cn/tag/design/) 设计一个支持 `push` ,`pop` ,`top` 操作,并能在常数时间内检索到最小元素的栈。 实现 `MinStack` 类: * `MinStack()` 初始化堆栈对象。 * `void push(int val)` 将元素val推入堆栈。 * `void pop()`...

# [152\. 乘积最大子数组](https://leetcode.cn/problems/maximum-product-subarray/) ## Description Difficulty: **中等** Related Topics: [数组](https://leetcode.cn/tag/array/), [动态规划](https://leetcode.cn/tag/dynamic-programming/) 给你一个整数数组 `nums` ,请你找出数组中乘积最大的非空连续子数组(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。 测试用例的答案是一个 **32-位** 整数。 **子数组** 是数组的连续子序列。 **示例 1:** ``` 输入: nums = [2,3,-2,4] 输出: 6 解释: 子数组...

# [148\. 排序链表](https://leetcode.cn/problems/sort-list/) ## Description Difficulty: **中等** Related Topics: [链表](https://leetcode.cn/tag/linked-list/), [双指针](https://leetcode.cn/tag/two-pointers/), [分治](https://leetcode.cn/tag/divide-and-conquer/), [排序](https://leetcode.cn/tag/sorting/), [归并排序](https://leetcode.cn/tag/merge-sort/) 给你链表的头结点 `head` ,请将其按 **升序** 排列并返回 **排序后的链表** 。 **示例 1:** ![](https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg) ``` 输入:head = [4,2,1,3] 输出:[1,2,3,4] ```...

# [146\. LRU 缓存](https://leetcode.cn/problems/lru-cache/) ## Description Difficulty: **中等** Related Topics: [设计](https://leetcode.cn/tag/design/), [哈希表](https://leetcode.cn/tag/hash-table/), [链表](https://leetcode.cn/tag/linked-list/), [双向链表](https://leetcode.cn/tag/doubly-linked-list/) 请你设计并实现一个满足  约束的数据结构。 实现 `LRUCache` 类: * `LRUCache(int capacity)` 以 **正整数** 作为容量 `capacity` 初始化 LRU 缓存 *...

# [142\. 环形链表 II](https://leetcode.cn/problems/linked-list-cycle-ii/) ## Description Difficulty: **中等** Related Topics: [哈希表](https://leetcode.cn/tag/hash-table/), [链表](https://leetcode.cn/tag/linked-list/), [双指针](https://leetcode.cn/tag/two-pointers/) 给定一个链表的头节点  `head` ,返回链表开始入环的第一个节点。 _如果链表无环,则返回 `null`。_ 如果链表中有某个节点,可以通过连续跟踪 `next` 指针再次到达,则链表中存在环。 为了表示给定链表中的环,评测系统内部使用整数 `pos` 来表示链表尾连接到链表中的位置(**索引从 0 开始**)。如果 `pos` 是 `-1`,则在该链表中没有环。**注意:`pos` 不作为参数进行传递**,仅仅是为了标识链表的实际情况。...

# [141\. 环形链表](https://leetcode.cn/problems/linked-list-cycle/) ## Description Difficulty: **简单** Related Topics: [哈希表](https://leetcode.cn/tag/hash-table/), [链表](https://leetcode.cn/tag/linked-list/), [双指针](https://leetcode.cn/tag/two-pointers/) 给你一个链表的头节点 `head` ,判断链表中是否有环。 如果链表中有某个节点,可以通过连续跟踪 `next` 指针再次到达,则链表中存在环。 为了表示给定链表中的环,评测系统内部使用整数 `pos` 来表示链表尾连接到链表中的位置(索引从 0 开始)。**注意:`pos` 不作为参数进行传递 **。仅仅是为了标识链表的实际情况。 _如果链表中存在环_ ,则返回 `true` 。 否则,返回...