09 2014 档案

[leetcode]Merge k Sorted Lists @ Python [基础知识: heap]
摘要:原题地址:https://oj.leetcode.com/problems/merge-k-sorted-lists/题意:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its com... 阅读全文

posted @ 2014-09-30 22:54 AIDasr 阅读(287) 评论(0) 推荐(0)

[leetcode] Largest Rectangle in Histogram @ Python [图解] [很难]
摘要:原题地址:https://oj.leetcode.com/problems/largest-rectangle-in-histogram/题意:Givennnon-negative integers representing the histogram's bar height where the ... 阅读全文

posted @ 2014-09-30 09:50 AIDasr 阅读(377) 评论(0) 推荐(0)

[leetcode] Count and Say @ Python
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文

posted @ 2014-09-30 06:34 AIDasr 阅读(287) 评论(0) 推荐(0)

[leetcode] Scramble String @python
摘要:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文

posted @ 2014-09-30 00:06 AIDasr 阅读(440) 评论(0) 推荐(0)

[leetcode]Symmetric Tree @ Python
摘要:原题地址:https://oj.leetcode.com/problems/symmetric-tree/题意:判断二叉树是否为对称的。Given a binary tree, check whether it is a mirror of itself (ie, symmetric around ... 阅读全文

posted @ 2014-09-29 02:08 AIDasr 阅读(879) 评论(0) 推荐(1)

[leetcode] Maximum Product Subarray @ python
摘要:[leetcode] Latest added:2014-09-23Find the contiguous subarray within an array (containing at least one number) which has the largest product.For exam... 阅读全文

posted @ 2014-09-27 22:33 AIDasr 阅读(450) 评论(0) 推荐(0)

[leetcode]Surrounded Regions @ Python
摘要:原题地址:https://oj.leetcode.com/problems/surrounded-regions/题意:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is cap... 阅读全文

posted @ 2014-09-24 10:40 AIDasr 阅读(243) 评论(0) 推荐(0)

[leetcode]N-Queens @ Python
摘要:原题地址:https://oj.leetcode.com/problems/n-queens/题意:经典的N皇后问题。解题思路:这类型问题统称为递归回溯问题,也可以叫做对决策树的深度优先搜索(dfs)。N皇后问题有个技巧的关键在于棋盘的表示方法,这里使用一个数组就可以表达了。比如board=[1, ... 阅读全文

posted @ 2014-09-21 10:45 AIDasr 阅读(419) 评论(0) 推荐(0)

[leetcode] Combinations @ Python [ask for help]
摘要:https://oj.leetcode.com/problems/combinations/Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If ... 阅读全文

posted @ 2014-09-20 09:16 AIDasr 阅读(134) 评论(0) 推荐(0)

[leetcode]Next Permutation @ Python
摘要:原题地址:https://oj.leetcode.com/problems/next-permutation/题意:Implement next permutation, which rearranges numbers into the lexicographically next greater... 阅读全文

posted @ 2014-09-20 06:57 AIDasr 阅读(555) 评论(0) 推荐(0)

[building block] merge sort @ Python
摘要:Here is the basic algorithm about merge sort:def merge(s1,s2,s): i=j=0 while i + j 0 and A[j-1] > cur: # element A[j-1] must be after current ... 阅读全文

posted @ 2014-09-18 10:28 AIDasr 阅读(344) 评论(0) 推荐(0)

[leetcode] Integer to Roman @ Python
摘要:题目: https://oj.leetcode.com/problems/integer-to-roman/Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from ... 阅读全文

posted @ 2014-09-17 06:40 AIDasr 阅读(158) 评论(0) 推荐(0)

[leetcode] Roman to Integer @ Python
摘要:题目:https://oj.leetcode.com/problems/roman-to-integer/Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1... 阅读全文

posted @ 2014-09-17 06:37 AIDasr 阅读(328) 评论(0) 推荐(0)

[leetcode] Add Binary @Python
摘要:题目:https://oj.leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "10... 阅读全文

posted @ 2014-09-16 09:32 AIDasr 阅读(948) 评论(0) 推荐(0)

[leetcode] Valid Palindrome @ Python
摘要:原题地址:https://oj.leetcode.com/problems/valid-palindrome/题意:Given a string, determine if it is a palindrome, considering only alphanumeric characters an... 阅读全文

posted @ 2014-09-16 07:09 AIDasr 阅读(629) 评论(0) 推荐(0)

[leetcode] LRU Cache @ Python
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文

posted @ 2014-09-16 02:50 AIDasr 阅读(827) 评论(0) 推荐(0)

[leetcode]Swap Nodes in Pairs @ Python
摘要:原题地址:http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2... 阅读全文

posted @ 2014-09-15 06:04 AIDasr 阅读(1929) 评论(1) 推荐(1)

[LeetCode] Reverse Linked List II @ Python [提供自创的示意图 Figure illustration]
摘要:原题地址:https://oj.leetcode.com/problems/reverse-linked-list-ii/题意:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Gi... 阅读全文

posted @ 2014-09-14 23:04 AIDasr 阅读(918) 评论(0) 推荐(0)

[leetcode]Add Two Numbers @ Python
摘要:原题地址:https://oj.leetcode.com/problems/add-two-numbers/题意:You are given two linked lists representing two non-negative numbers. The digits are stored i... 阅读全文

posted @ 2014-09-14 21:57 AIDasr 阅读(1484) 评论(0) 推荐(0)

[leetcode]Rotate Image, Matrix tranposition, matrix rotation 90 degree @ Python
摘要:原题地址:https://oj.leetcode.com/problems/rotate-image/题意:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Fo... 阅读全文

posted @ 2014-09-14 11:17 AIDasr 阅读(1459) 评论(0) 推荐(0)

[leetcode]Candy @ Python
摘要:原题地址:https://oj.leetcode.com/problems/candy/题意:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to ... 阅读全文

posted @ 2014-09-14 11:06 AIDasr 阅读(122) 评论(0) 推荐(0)

[leetcode]Gas Station @ Python
摘要:原题地址:https://oj.leetcode.com/problems/gas-station/题意:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You ha... 阅读全文

posted @ 2014-09-14 10:39 AIDasr 阅读(284) 评论(0) 推荐(0)

[leetcode]Gray Code @ Python
摘要:题意:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total n... 阅读全文

posted @ 2014-09-14 09:18 AIDasr 阅读(125) 评论(0) 推荐(0)

[leetcode]Plus One @ Python
摘要:原题地址:https://oj.leetcode.com/problems/plus-one/题意:Given a non-negative number represented as an array of digits, plus one to the number.The digits are... 阅读全文

posted @ 2014-09-14 04:58 AIDasr 阅读(216) 评论(0) 推荐(0)

[leetcode]Sudoku Solver @ Python
摘要:原题地址:https://oj.leetcode.com/problems/sudoku-solver/题意:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated b... 阅读全文

posted @ 2014-09-13 10:23 AIDasr 阅读(751) 评论(0) 推荐(0)

3Sum and 4Sum @ Python Leetcode
摘要:1)3Sumhttps://oj.leetcode.com/problems/3sum/Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the a... 阅读全文

posted @ 2014-09-12 10:18 AIDasr 阅读(242) 评论(0) 推荐(0)

[EPI] The knapsack problem with Python [17.7]
摘要:Reference:http://rosettacode.org/wiki/Knapsack_problem/0-1#Dynamic_programming_solutiontime complexity: O(limit*len(items))space complexity: O( limit... 阅读全文

posted @ 2014-09-05 10:16 AIDasr 阅读(301) 评论(0) 推荐(0)

[EPI] maximize fishing [17.5] python
摘要:def maximizeFishing(A): for i in range(len(A)): for j in range(len(A[0,:])): A[i][j] += max(0 if i < 1 else A[i - 1][j], 0 if j <... 阅读全文

posted @ 2014-09-04 07:07 AIDasr 阅读(123) 评论(0) 推荐(0)

导航