- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode:Gas Station
Gas Station There 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 346
原创 LeetCode:Candy
Candy There 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 338
原创 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 438
原创 LeetCode:Single Number
Single Number Given 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 287
原创 LeetCode:Copy List with Random Pointer
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 o
2014-09-11 14:49:35 311
原创 LeetCode:Word Break II
Word Break II Given 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 473
原创 LeetCode:Word Break
Word Break Given 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, given s = "leetcode",
2014-09-11 09:33:10 440
原创 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 326
原创 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 346
原创 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 339
原创 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 / 3 return [1,2,3]. Note: Recursive soluti
2014-08-30 16:09:40 316
原创 LeetCode:Binary Tree Postorder
题目如下: Given a binary tree, return the postorder traversal of its nodes' values. 1 \ 2 / 3 return [3,2,1]. Note: Recursive solution is trivial, could you do it iterative
2014-08-29 14:45:06 337
原创 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 375
原创 LeetCode:Insertion Sort List
Sort a linked list using insertion sort ListNode *insertionSortList(ListNode *head) { if(!head || !head->next) return head; ListNode* result =head; ListNode* p = head; ListNode* pre =NU
2014-08-26 17:05:22 367
原创 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 365
原创 LeedCode:Max Points on a Line
Max Points on a Line My Submissions Given 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 330
原创 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 713
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人