自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 【LeetCode记录】143. 重排链表

143. 重排链表 题目描述 给定一个单链表 L:L0→L1→…→Ln-1→Ln , 将其重新排列后变为: L0→Ln→L1→Ln-1→L2→Ln-2→… 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换。 示例 1: 给定链表 1->2->3->4, 重新排列为 1->4->2->3. 示例 2: 给定链表 1->2->3->4->5, 重新排列为 1->5->2->4->3. 来源:力扣(LeetCo

2020-10-21 00:22:46 82

原创 【LeetCode记录】99. 恢复二叉搜索树

99. 恢复二叉搜索树 题目描述 二叉搜索树中的两个节点被错误地交换。 请在不改变其结构的情况下,恢复这棵树。 示例 1: 输入: [1,3,null,null,2] 输出: [3,1,null,null,2] 示例 2: 输入: [3,1,4,null,null,2] 输出: [2,1,4,null,null,3] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/recover-binary-search-tree 解 思路:递归,在二叉搜索树中找到

2020-08-08 10:10:50 109

原创 【LeetCode记录】5476. 找出数组游戏的赢家

5476. 找出数组游戏的赢家 题目描述 给你一个由 不同 整数组成的整数数组 arr 和一个整数 k 。 每回合游戏都在数组的前两个元素(即 arr[0] 和 arr[1] )之间进行。比较 arr[0] 与 arr[1] 的大小,较大的整数将会取得这一回合的胜利并保留在位置 0 ,较小的整数移至数组的末尾。当一个整数赢得 k 个连续回合时,游戏结束,该整数就是比赛的 赢家 。 返回赢得比赛的整数。 题目数据 保证 游戏存在赢家。 示例 1: 输入:arr = [2,1,3,5,4,6,7], k = 2

2020-08-02 11:21:28 111

原创 【LeetCode记录】96. Unique Binary Search Trees

96. Unique Binary Search Trees 题目描述 Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n? 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/unique-binary-search-trees 递推 思路:当构造二叉排序树时,确定了根节点之后,左右子树仍然为二叉排序树,且规模更小。故使用一个数

2020-07-15 11:33:43 89

原创 【LeetCode记录】120. Triangle

120. Triangle 题目描述 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bo

2020-07-14 16:55:48 64

原创 【LeetCode记录】174. Dungeon Game

174. Dungeon Game 题目描述 The demons had captured the princess § and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and mu

2020-07-12 11:05:14 67

原创 【LeetCode记录】面试题 16.11. Diving Board LCCI

面试题 16.11. Diving Board LCCI 题目描述 You are building a diving board by placing a bunch of planks of wood end-to-end. There are two types of planks, one of length shorter and one of length longer. You must use exactly K planks of wood. Write a method to gener

2020-07-08 09:03:45 154 1

原创 【LeetCode记录】112. Path Sum

112. Path Sum 题目描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. Note: A leaf is a node with no children. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/prob

2020-07-07 09:12:18 69

原创 【LeetCode记录】63. Unique Paths II

63. Unique Paths II 题目描述 A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (m

2020-07-06 10:19:42 149

原创 【LeetCode记录】44. Wildcard Matching

44. Wildcard Matching 题目描述 Given an input string and a pattern, implement wildcard pattern matching with support for ‘?’ and ‘*’. ‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence). The matching should c

2020-07-05 17:12:11 60

原创 【LeetCode记录】32. Longest Valid Parentheses

32. Longest Valid Parentheses 题目描述 Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/longest-valid-parentheses 乍一看挺简单,就是简

2020-07-04 10:35:54 72

原创 【LeetCode记录】718. Maximum Length of Repeated Subarray

718. Maximum Length of Repeated Subarray 最一开始接触到这个题,想到的是KMP算法2333; 然后想到的是string.h:A中所有子串去B里找; 发现不是字符串而是数组,故暴力法变得更为简单。 暴力法 int findLength(int* A, int ASize, int* B, int BSize){ int i,j; int len = 0; int maxlen = 0; for(i = 0; i < ASize; i

2020-07-01 17:51:57 93

原创 【LeetCode记录】215. Kth Largest Element in an Array

215. Kth Largest Element in an Array 使用C完成,消耗空间开两个数组。 大小排序权重数组weight 相同数字出现次数数组times 源代码 int findKthLargest(int* nums, int numsSize, int k){ //初始化好权重数组 int weight[numsSize]; int i; for(i = 0; i < numsSize; i++){ weight[i] = 1;

2020-06-29 22:56:23 75

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除