Fork me on GitHub

02 2017 档案

摘要: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 cost 阅读全文
posted @ 2017-02-28 23:27 hellowOOOrld 阅读(164) 评论(0) 推荐(0)
摘要: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 re 阅读全文
posted @ 2017-02-28 17:25 hellowOOOrld 阅读(207) 评论(0) 推荐(0)
摘要:Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Update (2015-02-12): For C 阅读全文
posted @ 2017-02-28 15:10 hellowOOOrld 阅读(208) 评论(0) 推荐(0)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequ 阅读全文
posted @ 2017-02-27 14:56 hellowOOOrld 阅读(377) 评论(0) 推荐(0)
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文
posted @ 2017-02-26 23:31 hellowOOOrld 阅读(183) 评论(0) 推荐(0)
摘要: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. Fo 阅读全文
posted @ 2017-02-26 14:43 hellowOOOrld 阅读(158) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 判断链表是否带环,我们可以采用在头结点设两个指针,一个叫fast,一个叫slo 阅读全文
posted @ 2017-02-25 20:19 hellowOOOrld 阅读(180) 评论(0) 推荐(0)
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-02-25 17:40 hellowOOOrld 阅读(205) 评论(0) 推荐(0)
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Re 阅读全文
posted @ 2017-02-25 16:42 hellowOOOrld 阅读(209) 评论(0) 推荐(0)
摘要:Given a binary tree, return the preorder traversal of its nodes' values. Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti 阅读全文
posted @ 2017-02-25 15:21 hellowOOOrld 阅读(146) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort. 写的思路其实很朴素: 1.先将原链表一个结点摘下来。 2.插入到有序的新链表里的合适位置。 3.循环1、2步骤,直到原链表所有结点遍历完毕。 时间复杂度为O(n2),空间复杂度为O(1)。 阅读全文
posted @ 2017-02-24 22:58 hellowOOOrld 阅读(216) 评论(0) 推荐(0)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 利用归并排序的思想,递归合并两个有序的链表。 首先将链表递归分成两部分,直到只有一个结点为止,然后从底到上合并链表。 当然是学习大牛代码后写出的,如下: 阅读全文
posted @ 2017-02-24 19:45 hellowOOOrld 阅读(171) 评论(0) 推荐(0)
摘要:leetcode-149-Max Points on a Line 阅读全文
posted @ 2017-02-24 13:06 hellowOOOrld 阅读(261) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime comple 阅读全文
posted @ 2017-02-23 19:36 hellowOOOrld 阅读(157) 评论(0) 推荐(0)
摘要:You are given two non - empty linked lists representing two non - negative integers. The digits are stored in reverse order and each of their nodes co 阅读全文
posted @ 2017-02-23 16:38 hellowOOOrld 阅读(166) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文
posted @ 2017-02-23 12:34 hellowOOOrld 阅读(226) 评论(0) 推荐(0)
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-02-22 22:24 hellowOOOrld 阅读(177) 评论(0) 推荐(0)
摘要:求二叉树最小深度 阅读全文
posted @ 2017-02-19 18:36 hellowOOOrld 阅读(170) 评论(0) 推荐(0)
摘要:记录一下近期练习的剑指offer上的题目 阅读全文
posted @ 2017-02-19 13:56 hellowOOOrld 阅读(1012) 评论(0) 推荐(0)