The Employee table holds all employees including their managers. Every employee has an Id, an…
分类:LeetCode
[LeetCode] Factor Combinations 因子组合
Numbers can be regarded as product of its factors. For example, 8 = 2 x 2 x 2; = 2 x 4. Write a functio…
[LeetCode] Minimum Moves to Equal Array Elements 最少移动次数使数组元素相等
Given a non-empty integer array of size n, find the minimum number of moves required to …
[LeetCode] Subtree of Another Tree 另一个树的子树
Given two non-empty binary trees s and t, check whether tree t has exactly the…
[LeetCode] Split Linked List in Parts 拆分链表成部分
Given a (singly) linked list with head node root, write a function to split the linked list into&n…
LeetCode | Integer to Roman
题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999…
[Leetcode] Merge Two Sorted Lists Merge K Sorted Lists 归并有序列表
Merge Two Sorted Lists 最新更新请见:https://yanjia.me/zh/2019/01/… Merge two sorted linked lists and return it…
Leetcode PHP题解--D31 965. Univalued Binary Tree
965. Univalued Binary Tree 题目链接 965. Univalued Binary Tree 题目分析 如果二叉树中所有节点的值都相同,那么该二叉树被称为单值二叉树。 当给定的二叉树是单值二叉树时…
698. Partition to K Equal Sum Subsets
Medium L家的tag题,之前contest好像是做过但没有做出来当时,这道题看了答案然后写出了一个及其奇怪的bug. class Solution { public boolean canPartitionKSub…
二刷367. Valid Perfect Square
Easy mid*mid == num和mid == num/mid这两个不是完全等价的,要慎用,所以这种时候还是用long直接代替int来防止overflow比较稳
二刷560. Subarray Sum Equals K
Medium 一刷的笔记是直接复制粘贴过来的别人的语言,果然就完全没印象。虽然看似快,其实这样是最事倍功半的。一定要懂了,用自己的语言简单总结一下就好。别直接copy,没有意思。 第一种解法是O(N2)的brute fo…
55.跳跃游戏错在哪里
背景介绍 这是再次复习这道题目的遇到的问题 DP 状态 dp[i] 表示跳到i,包括i之后, 还剩余的跳跃步数. dp[0] 表示起点, dp[0]=nums[0] 排除法 dp 初始化过程没有问题 应该是dp 推导过程…