随笔分类 -  LeetCode

摘要:题目描述:(链接)Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be i... 阅读全文
posted @ 2015-11-05 22:59 skycore 阅读(157) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last... 阅读全文
posted @ 2015-11-04 16:05 skycore 阅读(139) 评论(0) 推荐(0)
摘要:题目描述:(链接)Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.解题思路: 1 class Sol... 阅读全文
posted @ 2015-11-03 16:27 skycore 阅读(128) 评论(0) 推荐(0)
摘要:题目描述: (链接)GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [... 阅读全文
posted @ 2015-11-03 15:52 skycore 阅读(126) 评论(0) 推荐(0)
摘要:题目描述:(链接)Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sort... 阅读全文
posted @ 2015-11-02 23:34 skycore 阅读(144) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Y... 阅读全文
posted @ 2015-11-01 18:13 skycore 阅读(109) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. ... 阅读全文
posted @ 2015-10-28 19:33 skycore 阅读(129) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->N... 阅读全文
posted @ 2015-10-27 23:33 skycore 阅读(151) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Give... 阅读全文
posted @ 2015-10-26 17:52 skycore 阅读(159) 评论(0) 推荐(0)
摘要:题目描述:(链接)Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -... 阅读全文
posted @ 2015-10-23 23:17 skycore 阅读(112) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3... 阅读全文
posted @ 2015-10-22 23:19 skycore 阅读(128) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve ... 阅读全文
posted @ 2015-10-22 23:06 skycore 阅读(143) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume tha... 阅读全文
posted @ 2015-10-21 11:26 skycore 阅读(138) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the fa... 阅读全文
posted @ 2015-10-21 10:54 skycore 阅读(130) 评论(0) 推荐(0)
摘要:题目描述:(链接)Reverse a singly linked list.解题思路:链表真讨厌,总是出错。头插法。 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *... 阅读全文
posted @ 2015-10-20 23:30 skycore 阅读(123) 评论(0) 推荐(0)
摘要:题目描述:(链接)Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5... 阅读全文
posted @ 2015-10-20 22:59 skycore 阅读(121) 评论(0) 推荐(0)
摘要:题目描述:(链接):Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For examp... 阅读全文
posted @ 2015-10-18 17:11 skycore 阅读(116) 评论(0) 推荐(0)
摘要:题目描述:(链接)There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the follow... 阅读全文
posted @ 2015-10-17 23:51 skycore 阅读(121) 评论(0) 推荐(0)
摘要:题目描述:(链接)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 c... 阅读全文
posted @ 2015-10-17 22:50 skycore 阅读(138) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra ... 阅读全文
posted @ 2015-10-15 23:41 skycore 阅读(145) 评论(0) 推荐(0)