题目描述 Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree …
分类:LeetCode题目解答
[Leetcode] Intersection of Two Linked Lists 链表交点
双指针法 复杂度 时间 O(N) 空间 O(1) 思路 先算出两个链表各自的长度,然后从较长的链表先遍历,遍历到较长链表剩余长度和较短链表一样时,用两个指针同时遍历两个链表。这样如果链表有交点的话,两个指针已经一定会相遇…
[Leetcode] Add Two Numbers 链表数相加
Add Two Numbers You are given two linked lists representing two non-negative numbers. The digits are stored in…
132. Palindrome Partitioning II
欢迎fork and star:Nowcoder-Repository-github 132. Palindrome Partitioning II 题目 Given a string s, partition s su…
[LeetCode] Walls and Gates 墙和门
You are given a m x n 2D grid initialized with these three possible values. -1 – A wall or an obs…
LeetCode | Length of Last Word
题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', ret…
217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates.Your function should return true if any …
[Leetcode] Longest Valid Parentheses 最长有效括号对
Longest Valid Parentheses Given a string containing just the characters ‘(‘ and ‘)’, f…
59. Spiral Matrix II
59. Spiral Matrix II 题目 Given an integer n, generate a square matrix filled with elements from 1 to n2 in spir…
[LeetCode] Contains Duplicate 包含重复值,Contains Duplicate II 包含重复值之二
Given an array of integers, find if the array contains any duplicates. Your function should return true…
[LeetCode] Next Closest Time 下一个最近时间点
Given a time represented in the format “HH:MM”, form the next closest time by reusing the c…
LeetCode 203 Remove Linked List Elements
题目描述 Remove all elements from a linked list of integers that have value val. Example Given: 1 –> 2 –> 6 …