xinyu04

导航

上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页

2022年7月19日 #

LeetCode 19 Remove Nth Node From End of List 链表节点删除+双指针

摘要: Given the head of a linked list, remove the $n$-th node from the end of the list and return its head. Solution 首先在原链表开头设置新头节点,然后先用 $fast$ 指针移动 $n$ 个单位 阅读全文

posted @ 2022-07-19 17:06 Blackzxy 阅读(11) 评论(0) 推荐(0) 编辑

LeetCode 226 Invert Binary Tree DFS

摘要: Given the root of a binary tree, invert the tree, and return its root. Solution: 直接使用 $DFS$ 进行递归即可: 点击查看代码 /** * Definition for a binary tree node. * 阅读全文

posted @ 2022-07-19 04:13 Blackzxy 阅读(12) 评论(0) 推荐(0) 编辑

[Google] LeetCode 366 Find Leaves of Binary Tree 思维+DFS

摘要: Given the root of a binary tree, collect a tree's nodes as if you were doing this: Collect all the leaf nodes. Remove all the leaf nodes. Repeat until 阅读全文

posted @ 2022-07-19 02:57 Blackzxy 阅读(14) 评论(0) 推荐(0) 编辑

2022年7月18日 #

[Google] LeetCode 818 Race Car 贪心+思维

摘要: Your car starts at position $0$ and speed $+1$ on an infinite number line. Your car can go into negative positions. Your car drives automatically acco 阅读全文

posted @ 2022-07-18 21:47 Blackzxy 阅读(32) 评论(0) 推荐(0) 编辑

[Google] LeetCode 1293 Shortest Path in a Grid with Obstacles Elimination 思维+BFS+贪心

摘要: You are given an m x n integer matrix grid where each cell is either $0$ (empty) or $1$ (obstacle). You can move up, down, left, or right from and to 阅读全文

posted @ 2022-07-18 03:36 Blackzxy 阅读(15) 评论(0) 推荐(0) 编辑

2022年7月17日 #

LeetCode 376 Wiggle Subsequence DP+思维

摘要: A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first differenc 阅读全文

posted @ 2022-07-17 02:47 Blackzxy 阅读(7) 评论(0) 推荐(0) 编辑

2022年7月16日 #

LeetCode 704 Binary Search 模板

摘要: Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists 阅读全文

posted @ 2022-07-16 03:38 Blackzxy 阅读(10) 评论(0) 推荐(0) 编辑

2022年7月15日 #

LeetCode Largest Rectangle in Histogram 思维

摘要: Given an array of integers heights representing the histogram's bar height where the width of each bar is $1$, return the area of the largest rectangl 阅读全文

posted @ 2022-07-15 22:17 Blackzxy 阅读(12) 评论(0) 推荐(0) 编辑

LeetCode Longest Increasing Path in a Matrix 记忆化搜索+DP [Hard]

摘要: Given an $m \times n$ integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directi 阅读全文

posted @ 2022-07-15 05:09 Blackzxy 阅读(14) 评论(0) 推荐(0) 编辑

2022年7月14日 #

LeetCode Gas Station 数学

摘要: There are n gas stations along a circular route, where the amount of gas at the $i$th station is gas[i]. You have a car with an unlimited gas tank and 阅读全文

posted @ 2022-07-14 21:56 Blackzxy 阅读(15) 评论(0) 推荐(0) 编辑

上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 30 下一页