- 博客(54)
- 收藏
- 关注
原创 Python Web Development with Flask
1. Flask1.1 How Flask Routing Works…2. Flask-Admin…3. Flask-SQLAlchemy…AlembicQ1: How to clear history and run all migrations from the beginning?A1: Following works in Vagrant, dropdb SNEAKERBANK crea
2016-11-10 19:29:57 437
转载 Python中的多继承
Python和C++一样,支持多继承。概念虽然容易,但是困难的工作是如果子类调用一个自身没有定义的属性,它是按照何种顺序去到父类寻找呢,尤其是众多父类中有多个都包含该同名属性。class P1 #(object): def foo(self): print 'p1-foo' class P2 #(object): def foo(self):
2016-11-25 12:01:04 439
原创 [TODO]LeetCode 37. Sudoku Solver
Problem Statement(Source) Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.
2016-11-15 22:47:24 280
原创 LeetCode 282. Expression Add Operators
Problem Statement(Source) Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to
2016-11-14 21:32:35 345
原创 LeetCode 327. Count of Range Sum
Problem Statement(Source) Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between ind
2016-11-14 08:57:27 423
原创 LeetCode 432. All O`one Data Structure
Problem Statement(Source) Implement a data structure supporting the following operations:Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-em
2016-11-13 23:32:10 871
原创 LeetCode 381. Insert Delete GetRandom O(1) - Duplicates allowed
Problem Statement(Source) Design a data structure that supports all following operations in average O(1) time.Note: Duplicate elements are allowed.insert(val): Inserts an item val to the collection.r
2016-11-13 23:02:18 244
原创 LeetCode 126. Word Ladder II
Problem Statement(Source) Given two words (beginWord and endWord), and a dictionary’s word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:Only one letter can b
2016-11-13 21:42:05 706
原创 LeetCode 127. Word Ladder
(Source) Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed
2016-11-13 19:00:07 271
原创 LeetCode 44. Wildcard Matching
Problem Statement(Source) Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The ma
2016-11-13 15:55:31 238
原创 LeetCode 456. 132 Pattern
Problem Statement(Source) Given a sequence of n integers a1,a2,...,ana_1, a_2, ..., a_n, a 132 pattern is a subsequence ai,aj,aka_i, a_j, a_k such that i < j < k and ai<ak<aja_i < a_k < a_j. Design an
2016-11-13 14:26:15 916
原创 LeetCode 454. 4Sum II
Problem Statement(Source) Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A,
2016-11-13 14:10:41 854
原创 LeetCode 459. Repeated Substring Pattern
Problem Statement(Source) Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string co
2016-11-13 11:37:19 915
原创 LeetCode 455. Assign Cookies
Problem Statement(Source) Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gig_i, which
2016-11-13 11:16:33 623
原创 LeetCode 335. Self Crossing
Problem Statement(Source) You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3] metre
2016-11-13 09:23:49 254
原创 LeetCode 324. Wiggle Sort II
Problem Statement(Source) Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5,
2016-11-13 08:41:36 254
原创 LeetCode 458. Poor Pigs
Problem Statement(Source) There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 min
2016-11-12 18:36:45 2107
原创 LeetCode 457. Circular Array Loop
Problem Statement(Source) You are given an array of positive and negative integers. If a number n at an index is positive, then move forward n steps. Conversely, if it’s negative (-n), move backward n
2016-11-12 18:10:46 1673
原创 LeetCode 451. Sort Characters By Frequency
Problem Statement(Source) Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both app
2016-11-12 17:43:36 609
原创 LeetCode 450. Delete Node in a BST
Problem Statement(Source) Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically, the dele
2016-11-12 17:34:29 605
原创 LeetCode 449. Serialize and Deserialize BST
Problem Statement(Source) Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a netw
2016-11-12 16:58:35 542
原创 LeetCode 448. Find All Numbers Disappeared in an Array
Problem Statement(Source) Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appe
2016-11-12 16:50:52 1003
原创 LeetCode 445. Add Two Numbers II
Problem Statement(Source) You are given two linked lists representing two non-negative numbers. The most significant digit comes first and each of their nodes contain a single digit. Add the two number
2016-11-12 16:37:30 768
原创 LeetCode 433. Minimum Genetic Mutation
Problem Statement(Source) A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T".Suppose we need to investigate about a mutation (mutation from “start” to
2016-11-12 16:18:44 1633
原创 LeetCode 437. Path Sum III
Problem Statement(Source) You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root
2016-11-12 11:24:47 297
原创 LeetCode 407. Trapping Rain Water II
Problem Statement(Source) Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:
2016-11-08 22:29:55 337
原创 LeetCode 400. Nth Digit
Problem Statement(Source) Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …Note: n is positive and will fit within the range of a 32-bit signed integer (n < 2312
2016-11-07 23:17:42 253
原创 [TODO]LeetCode 85. Maximal Rectangle
Problem Statement(Source) Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1
2016-11-07 20:59:51 211
原创 LeetCode 174. Dungeon Game
Problem Statement(Source) The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant kni
2016-11-07 20:45:29 232
原创 LeetCode 179. Largest Number
Problem Statement(Source) Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The
2016-11-07 09:17:57 190
原创 LeetCode 88. Merge Sorted Array
Problem Statement(Source) Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to
2016-11-07 08:53:40 208
原创 LeetCode 384. Shuffle an Array
Problem Statement(Source) Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);// Shuffle the array [1
2016-11-07 08:39:29 167
原创 LeetCode 42. Trapping Rain Water
Problem Statement(Source) Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1
2016-11-06 21:58:56 306
原创 LeetCode 447. Number of Boomerangs
Problem Statement(Source) Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i a
2016-11-06 10:36:48 1085
原创 LeetCode 446. Arithmetic Slices II - Subsequence
Problem Statement(Source) A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these
2016-11-06 10:30:49 2332
原创 LeetCode 453. Minimum Moves to Equal Array Elements
Problem Statement(Source) Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example
2016-11-06 10:04:16 1183
原创 LeetCode 452. Minimum Number of Arrows to Burst Balloons
Problem Statement(Source) There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since i
2016-11-06 10:00:18 773
原创 LeetCode 390. Elimination Game
Problem Statement(Source) There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.Repea
2016-11-05 19:42:58 313
原创 LeetCode 398. Random Pick Index
Problem Statement(Source) Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.No
2016-11-05 19:20:28 334
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人