- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode:Gas Station
Gas StationThere are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas t
2014-09-12 10:37:58 366
原创 LeetCode:Candy
CandyThere are N children 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
2014-09-12 10:34:34 353
原创 LeetCode:Single NumberII
int singleNumber(int A[], int n) { int result = 0; int INT_SIZE = sizeof(int)*8; int* count = new int[INT_SIZE]; memset(count,0,INT_SIZE*sizeof(int)); for(int i = 0;i<n;i++) {
2014-09-12 10:31:07 450
原创 LeetCode:Single Number
Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement i
2014-09-11 15:13:46 301
原创 LeetCode:Copy List with Random Pointer
Copy List with Random PointerA 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 o
2014-09-11 14:49:35 337
原创 LeetCode:Word Break II
Word Break IIGiven a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.
2014-09-11 09:45:33 487
原创 LeetCode:Word Break
Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",
2014-09-11 09:33:10 456
原创 LeedCode:Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?
2014-08-31 17:44:11 345
原创 LeetCode: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?
2014-08-31 16:48:25 364
原创 LeetCode:Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t
2014-08-30 17:27:54 356
原创 LeetCode:Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive soluti
2014-08-30 16:09:40 331
原创 LeetCode:Binary Tree Postorder
题目如下:Given a binary tree, return the postorder traversal of its nodes' values. 1 \ 2 / 3return [3,2,1].Note: Recursive solution is trivial, could you do it iterative
2014-08-29 14:45:06 351
原创 LeetCode:LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2014-08-28 14:55:20 399
原创 LeetCode:Insertion Sort List
Sort a linked list using insertion sortListNode *insertionSortList(ListNode *head) { if(!head || !head->next) return head; ListNode* result =head; ListNode* p = head; ListNode* pre =NU
2014-08-26 17:05:22 390
原创 LeedCode:Sort List
Sort a linked list in O(n log n) time using constant space complexity.一、kuai'su'pai's
2014-08-26 16:19:09 380
原创 LeedCode:Max Points on a Line
Max Points on a Line My SubmissionsGiven n points on a 2D plane, find the maximum number of points that lie on the same straight line.
2014-08-25 15:03:11 345
原创 Evaluate the value of an arithmetic expression in Reverse Polish Notation.
int evalRPN(vector &tokens){stack operand; for(int i = 0;i < tokens.size(); i++) { if(isOperator(tokens[i])) { char op = tokens[i].at(0); int operand2 = operand.top(); operand.pop();
2014-08-21 18:23:05 732
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人