上一页 1 2 3 4 5 6 7 ··· 11 下一页

2014年4月3日

再接再厉

摘要: 今天看到了阿里实习终面通过的消息,非常开心,同时也为天龙感到惋惜。阿里实习的这三面通过,可以说运气还是占了一定成分的,我不大会的东西都没怎么问,问的大都是撞到我的枪口下的,因此比较顺利。如果再来一次,把那些恶心的问题都问我,未必能够走到这一步。这段时间,真的非常感谢天龙和文清,大家有消息第一时间互相通知,有问题互相沟通,一同学习一起讨论算法,无论结果如何,这一阵子是我提升非常快的一段时间。人须有自知之明,如果没有天龙和文清,我是不可能如此顺利走到这一步的。面试阶段暴露了很多问题,基础还需要进一步掌握。如果对待一个问题,不能拿出最佳的算法,这个问题就不算解决。要感谢的人还有很多,我亲爱的高中同学 阅读全文

posted @ 2014-04-03 17:45 pengyu2003 阅读(163) 评论(0) 推荐(0) 编辑

2014年3月31日

Gas Station

摘要: There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from stationito its next station (i+1). You begin the journey with an empty tank at one of the gas stations.Return the starting gas 阅读全文

posted @ 2014-03-31 16:18 pengyu2003 阅读(213) 评论(0) 推荐(0) 编辑

2014年3月28日

一淘二面

摘要: 仔细想想,越来越感觉自己的代码写的烂,不是一般的烂……还是太紧张了,希望能够迅速成长,起码别再这么紧张。两个题:1.链表反转2.#切割字符都是很简单的题。虽然结果问题不大,代码写那么差,实在是太丢人了,对不起实验室,对不起师兄…… 阅读全文

posted @ 2014-03-28 16:52 pengyu2003 阅读(144) 评论(0) 推荐(1) 编辑

2014年3月26日

Candy

摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you mu 阅读全文

posted @ 2014-03-26 22:53 pengyu2003 阅读(109) 评论(0) 推荐(0) 编辑

Single Number

摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.和上一题比这题就是渣。class Solution {public: int singleNumber(int A[], int n) { if(A == NULL)return 0; int re = 0; for(int i = 0 ; i < n ;i++)re ^= A[i]; return re; }}; 阅读全文

posted @ 2014-03-26 21:50 pengyu2003 阅读(93) 评论(0) 推荐(0) 编辑

Single Number II

摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?本题最好理解版本有的数字出现3次,个别出现1次,因此每出现3次就可以归零了。我们用三个量分别记录出现1次、2次、3次(其实就是0次)的位,分别为x1,x2,x3.某一位出现1次,可能之 阅读全文

posted @ 2014-03-26 21:45 pengyu2003 阅读(182) 评论(0) 推荐(0) 编辑

Copy List with Random Pointer

摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.这题貌似见过,大概是编程之美之类吧。复习一下深拷贝和浅拷贝的区别:深拷贝保存了指针指向的内容,二浅拷贝应对指针指示给指针赋值。所以对于有指针的地方,浅拷贝非常不安全。这段代码用了2个栈,感觉很不效率,空间O(n)。有个空间O(1)的。/** * Definition for 阅读全文

posted @ 2014-03-26 19:57 pengyu2003 阅读(117) 评论(0) 推荐(0) 编辑

Word Break

摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For example, givens="leetcode",dict=["leet", "code"].Return true because"leetcode"can be segmented as"leet code&quo 阅读全文

posted @ 2014-03-26 18:50 pengyu2003 阅读(129) 评论(0) 推荐(0) 编辑

Linked List Cycle

摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?更简单的环题/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool has... 阅读全文

posted @ 2014-03-26 16:35 pengyu2003 阅读(119) 评论(0) 推荐(0) 编辑

Linked List Cycle II

摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?老题,没难度。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * ... 阅读全文

posted @ 2014-03-26 16:30 pengyu2003 阅读(96) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 11 下一页

导航