2013年9月14日

摘要: n个无序整数,已知第i个数在排好序的序列中的位置为j,满足|i-j|<=K,请设计一种排序算法,对该序列进行排序。注:算法时间复杂度为O(nlgn)的得0分,复杂度为O(nk)的得两分,总分是20分。 答:由以上条件判断最小的数字一定在前k个中,于是可以讲前k个数建立一个最小堆,然后把根元素取出,该根元素就是最小数,然后将第k+1个数放入堆中,因为第二小的数字肯定在下标为1到k+1的位置范围内,所以调整最小堆之后,根元素就是第二小元素,取出该元素,将第k+2个元素放入堆中,……以此类推,按照元素从堆中取出的顺序就是已经排好序的序列。该算法时间复杂度为O(nlgk),确切的说是(n-k)l 阅读全文
posted @ 2013-09-14 16:22 highstar88 阅读(134) 评论(0) 推荐(0) 编辑

2013年8月13日

摘要: 撰写简历主要原则:1、在能够突出展现自己的工作履历、技能和优势的前提下,尽可能缩短篇幅(一页最佳),冗长的简历会冲淡重点,不易被HR所青睐。2、撰写简历前,尽可能通过各种途径了解职位所需的经验、素质和技能,并据此有针对性地制作相应的简历,只有这样才能让HR在“scan”简历的过程中,发现你和职位的匹配点,从而帮助他们找到面试你的理由。3、各类与应聘职位相关的实践或实习经验是企业HR最为关注的内容,务必将自己的实践内容及锻炼和提高的能力进行较详细地描述。同时,描写中要注重采用量化的指标强调成功经验,因为HR认为,从一个人既往的成功经验中,可以有效地推断出其未来在相关领域的成功概率。4、一定要让自 阅读全文
posted @ 2013-08-13 09:57 highstar88 阅读(224) 评论(0) 推荐(0) 编辑

2013年6月17日

摘要: Easy!Best Sufficient: O(n)class Solution {public: int lengthOfLongestSubstring(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function bool hash[26]; for(int i=0; i<26; i++) { hash[i] = false; } ... 阅读全文
posted @ 2013-06-17 11:38 highstar88 阅读(129) 评论(0) 推荐(0) 编辑

2013年5月4日

摘要: class Solution {public: int removeDuplicates(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (n == 0) return 0; int p=0; int q=1; while(q<n) { if(A[q]==A[p]) { ... 阅读全文
posted @ 2013-05-04 09:24 highstar88 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Easy!O(n) 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 7 int p=0; 8 int q=0; 9 while(q<n)10 {11 if(A[q]==elem)1... 阅读全文
posted @ 2013-05-04 09:11 highstar88 阅读(136) 评论(0) 推荐(0) 编辑

2013年5月3日

摘要: Resume/Curriculum vitae/biographical notes!!!LeetCode - 4Problems per Day * 35Days. 阅读全文
posted @ 2013-05-03 20:29 highstar88 阅读(126) 评论(0) 推荐(0) 编辑
摘要: note the edge cases!Easy! 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 ListNode *swapPairs(ListNode *head) {12 // Start typing ... 阅读全文
posted @ 2013-05-03 20:22 highstar88 阅读(324) 评论(0) 推荐(0) 编辑
摘要: converse the question to : find the minimum of (3Sum-target). We can also put the (-target) to the array~similar to the 3Sum,only change the find condition a bit!Note:assume that each input would have exactly one solutionTime Complexity: O(n^2)Space Complexity: O(1) 1 bool compare(const int& a, 阅读全文
posted @ 2013-05-03 19:45 highstar88 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Easy! 1 class Solution { 2 public: 3 int reverse(int x) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function 6 7 int revnum = 0; 8 int remainder = 0; 9 int quotient;10 11 if(x > 0) quotient = x;12 ... 阅读全文
posted @ 2013-05-03 15:59 highstar88 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution {10 public:11 ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) {12 // Start typing your C/C+... 阅读全文
posted @ 2013-05-03 15:29 highstar88 阅读(125) 评论(0) 推荐(0) 编辑

导航