- 博客(19)
- 资源 (2)
- 收藏
- 关注
原创 LeetCode—161. One Edit Distance
Binary Tree Upside Down思路:其实分类讨论更容易一次过,考虑长度相等和差1的情况,特别注意,s.equals(t)是falseGitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution {
2016-09-29 19:39:44 603
原创 LeetCode—156. Binary Tree Upside Down
Binary Tree Upside Down思路:显然是递归去做的GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。/** * Definition for a binary tree node. * public class TreeNod
2016-09-29 14:36:49 554
原创 LeetCode—406. Queue Reconstruction by Height
Queue Reconstruction by Height思路:随便找个方式排序,然后再按照插入排序找他们的位置,我选择的是先按k排顺序,k相同按h排顺序GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solu
2016-09-27 14:19:51 1717
原创 LeetCode—405. Convert a Number to Hexadecimal
Convert a Number to Hexadecimal思路:改成long,负数求出对应的数值,再处理GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public String toH
2016-09-27 11:27:02 1036
原创 LeetCode—404. Sum of Left Leaves
Sum of Left Leaves思路:智障题目GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。/** * Definition for a binary tree node. * public class TreeNode {
2016-09-27 10:47:21 887
原创 LeetCode—400. Nth Digit
Nth Digit思路:好像不用动态规划也能实现。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public int findNthDigit(int n) { int lengt
2016-09-21 10:00:01 883
原创 LeetCode—403. Frog Jump
Frog Jump思路:好像不用动态规划也能实现。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { int[] stones; int[][] ans; public bool
2016-09-19 13:24:43 1228
原创 LeetCode—402. Remove K Digits
Binary Watch思路:贪心算法,本来写的而是递归,然后栈溢出了,改成循环了。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public String removeKdigits(S
2016-09-19 13:15:55 565
原创 LeetCode—401. Binary Watch
Binary Watch思路:打表。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { Map> minuteMap = new HashMap>() { {
2016-09-19 10:13:02 842
原创 LeetCode—390. Elimination Game
Elimination Game思路:逐个删除的思路肯定是超时的。注意到第一次1……n从左到右删除后剩下的是2,4,6,8……这个问题等效于1……n/2(向下取证)从右往左的答案*2。那么再考虑从右往左1……2k+1,和从左往右的效果是等同的,1……2k,则剩下1,3,5,7,9,……等效于2a-1那么可以递归求解。GitHub地址:https://gi
2016-09-18 12:06:55 2666
原创 LeetCode—398. Random Pick Index
Integer Replacement思路:注意The array size can be very large. Solution that uses too much extra space will not pass the judge.不能开辟额外空间,所以更换随机方式。GitHub地址:https://github.com/corpse
2016-09-12 17:52:57 939
原创 LeetCode—396. Rotate Function
Integer Replacement思路:F[i]=F[i-1]+sum-n*A[n-i]GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public int maxRotateFunct
2016-09-12 17:45:52 653
原创 LeetCode—397. Integer Replacement
Integer Replacement思路:动态规划,注意各种边界条件GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { Map map; public int integerRepla
2016-09-12 16:32:45 878
原创 LeetCode—167. Two Sum II - Input array is sorted
Two Sum II - Input array is sorted思路:弱智题目GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public int[] twoSum(int[]
2016-09-09 16:39:12 386
原创 LeetCode—391. Perfect Rectangle
Perfect Rectangle思路:核心思路2点:1,存储每个点,求出最后只出现奇数次的。判断最后是否只剩下4个。2.求每个矩形的总面积,判断是否和最后4个点构成的面积相等(防止内部重叠)GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public
2016-09-08 16:07:36 610
原创 LeetCode—394. Decode String
Decode String思路:先遍历String,找到少于k的字母,然后以这些字母split字符串,再将字符串递归调用方法。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public i
2016-09-07 11:20:12 378
原创 LeetCode—394. Decode String
Decode String思路:逐个char解析即可GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public String decodeString(String s) {
2016-09-06 10:59:39 868
原创 LeetCode—393. UTF-8 Validation
UTF-8 Validation思路:很简单,看注释即可。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public boolean validUtf8(int[] dat
2016-09-06 09:58:04 678
原创 LeetCode—392. Is Subsequence
Is Subsequence思路:贪心算法,直接两个index去逐个比较s和t即可。GitHub地址:https://github.com/corpsepiges/leetcode点此进入如果可以的话,请点一下star,谢谢。public class Solution { public boolean isSubsequence(
2016-09-06 09:29:39 753
2积分系列——经典算法与人工智能在外卖物流调度中的应用
2018-04-26
Outlier Analysis 2nd Edition.pdf ——2积分系列
2018-03-28
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人