- 博客(15)
- 资源 (1)
- 收藏
- 关注
原创 pat 1098 Insertion or Heap Sort
According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input dat
2015-09-30 19:59:26 272
原创 pat 1097 Deduplication on a Linked List
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a
2015-09-29 23:25:40 320
原创 pat 1096 Consecutive Factors
Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now given
2015-09-29 10:14:57 373
原创 pat 1099 Build A Binary Search Tree
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right
2015-09-27 23:53:48 359
原创 pat 1103 Integer Factorization
The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any positive
2015-09-27 14:04:51 608
原创 pat 1102 Invert a Binary Tree
The following is from Max Howell @twitter: Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off. Now it's your turn
2015-09-27 14:00:12 582
原创 AnguarJS $apply和$digesty
数据绑定意味着当View中有任何数据发生了变化,那么这个变化也会自动反馈到Scope数据上,也即意味着Scope模型会自动更新。类似地,当Scope模型发生变化时,view中的数据也会得到更新到最新的值。 那么Angularjs是如何做到这一点的呢? 当写下表达式如{{aModel}}时,Angularjs在幕后会为你在Scope模型上设置个watcher,它用来在数据发生变化
2015-09-25 23:42:10 425
原创 Leetcode226 Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howe
2015-09-12 13:10:10 356
原创 Leetcode 227 Basic Calculator II
Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should
2015-09-12 00:11:49 368
原创 Leetcode 228 Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. public class Solution228 { public List
2015-09-07 23:57:44 275
原创 Leetcode229 Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. public class Solution229 { public List
2015-09-04 22:53:48 270
原创 Leetcode230 Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements. Follow up: What if t
2015-09-02 22:54:36 263
原创 Leetcode231 Power of Two
Given an integer, write a function to determine if it is a power of two. public class Solution231 { public boolean isPowerOfTwo(int n) { if(n==1) return true; if(n%2 == 1) re
2015-09-01 23:08:00 279
原创 leetcode 232 Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(
2015-09-01 22:42:21 292
原创 Leetcode233 Number of Digit One
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example: Given n = 13, Return 6, because digit 1 occurred in the follow
2015-09-01 08:28:53 373
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人