摘要: 什么是Exceptions 首先我们要知道什么是Exceptions, 定义如下 Exceptions: An exception is an event that occurs during the execution of a program that disrupts the normal f 阅读全文
posted @ 2017-02-12 17:00 dapanshe 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 1,Every identifier in a Java program has a type associated with it. 当你使用任何variable的时候,第一件事情是告诉你可爱的编译器它到底是是个什么类型!!! 2,AP Java 考到的类型包括 (primitive type) 阅读全文
posted @ 2017-02-11 13:48 dapanshe 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 233 Number of Digit One这道题是递归算法class Solution: # @param {integer} n # @return {integer} def countDigitOne(self, n): if n <= 0: ... 阅读全文
posted @ 2015-08-12 05:27 dapanshe 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 018 4Sum感觉最差的情况应该是O(n*n*n)的复杂度from collections import defaultdictclass Solution: # @param {integer[]} nums # @param {integer} target # @retur... 阅读全文
posted @ 2015-08-10 12:51 dapanshe 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 029 Divide Two Integersclass Solution: # @param {integer} dividend # @param {integer} divisor # @return {integer} def divide(self, dividen... 阅读全文
posted @ 2015-08-08 14:39 dapanshe 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 166 Fraction to Recurring Decimal这道题就是不停的去check做除法的余数是否重复出现了class Solution: # @param {integer} numerator # @param {integer} denominator # @re... 阅读全文
posted @ 2015-08-07 14:00 dapanshe 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 220 Contains Duplicate III这道题用dic来记录上一次桶区间内的下标,唯一的trick是比较周边的一共三个桶class Solution: # @param {integer[]} nums # @param {integer} k # @param {in... 阅读全文
posted @ 2015-08-07 02:46 dapanshe 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 099 Recover Binary Search Tree没有按照要求用 constant space.... 用valid BST 找出两个not in order 的nodesclass Solution: def recoverTree(self, root): [fN,... 阅读全文
posted @ 2015-08-06 05:25 dapanshe 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 105 Construct Binary Tree from Preorder and Inorder Traversal这道题纯递归class Solution: # @param {integer[]} preorder # @param {integer[]} inorder ... 阅读全文
posted @ 2015-08-06 01:45 dapanshe 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 214 Shortest Palindrome这道题会用到一个算法在 这里用过利用这个算法稍作改进即可class Solution: def shortestPalindrome(self, s): T = '#'.join('${}&'.format(s)) an... 阅读全文
posted @ 2015-08-06 00:34 dapanshe 阅读(92) 评论(0) 推荐(0) 编辑