上一页 1 2 3 4 5 6 7 8 9 ··· 43 下一页
摘要: 要注意边和节点数是不一样的 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None cl 阅读全文
posted @ 2020-01-31 08:59 阿牧遥 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 其实暴力也能解,因为就4*4*4*4种 class Solution: def findNext(self, char, nums): i = 0 while i < len(nums): if nums[i] == char: if i != len(nums) - 1: return nums[ 阅读全文
posted @ 2020-01-31 00:27 阿牧遥 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 使用bucket class Solution: def kEmptySlots(self, bulbs: List[int], K: int) -> int: size = len(bulbs) // (K + 1) + 1 maxBuckets = [None] * size minBucket 阅读全文
posted @ 2020-01-30 13:50 阿牧遥 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 一开始想不出来,后来看了题解。 就是先重复A,知道length大于等于B;如果还不行,那么再加一次A,试一下,就足以。否则和前者是第一个长度大于等于B的假设矛盾。 class Solution: def repeatedStringMatch(self, A: str, B: str) -> int 阅读全文
posted @ 2020-01-30 09:30 阿牧遥 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 本人小弱,面试过了Google的HC,虽然team match还没完成,到最后还有变数。但对自己这段时间的努力,也算一个交代了。最初是一年半前Google的HR联系到我,然后第一次在电面就挂了。经过又一年准备,这次四轮面试感觉都不难,虽然面得不完美,感觉自身进步还是巨大的。需要指出的是面试绝不仅仅是... 阅读全文
posted @ 2015-03-06 00:35 阿牧遥 阅读(2310) 评论(9) 推荐(2) 编辑
摘要: dp,精华是从右下角开始。class Solution {public: int calculateMinimumHP(vector > &dungeon) { int m = dungeon.size(); int n = dungeon[0].size(); ... 阅读全文
posted @ 2015-02-15 11:22 阿牧遥 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 试了一把树状数组,代码果然很简单。#include #include #include #include #include #include using namespace std;vector cnt;vector arr; // effective index: 1..Nint lowb(int... 阅读全文
posted @ 2015-02-09 14:54 阿牧遥 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 第一题,送分题。第二题,#include #include #include #include using namespace std;class TravellingSalesmanEasy {public: int getMaxProfit(int M, vector profit, vec... 阅读全文
posted @ 2015-02-05 21:45 阿牧遥 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 第一题:K等于1或者2,非常简单。略。K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考。第二题:http://www.cnblogs.com/lautsie/p/4245242.htmlBFS和DFS都可以,注意的是,写的时候,可以往... 阅读全文
posted @ 2015-01-24 20:48 阿牧遥 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076模拟就可以了。#include #include using namespace std;class Target {public: vector... 阅读全文
posted @ 2015-01-24 20:39 阿牧遥 阅读(193) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 43 下一页