![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
忧桑的小兔子
天空飘来五个字,飘来三个字;天空飘来三个字,五个字.
展开
-
LRU - Python实现
github#!/usr/bin/python3.6# -*- coding: utf-8 -*-"""参考: https://zhuanlan.zhihu.com/p/34133067"""from typing import Dict, Anyclass Node(object): """ 双向链表节点 """ def __init__(self, key...原创 2019-12-04 23:37:45 · 657 阅读 · 0 评论 -
多元一次不定方程解的个数
```python#!/usr/bin/python3.6# -*- coding: utf-8 -*-"""多元一次不定方程解的个数problem1: 将30条鱼放入10个桶中, 每个桶至少一条鱼, 总共有多少种方法?本质: x1 + x2 + x3 + x4 + ... + xi = n, xi > 0, n > i 本题: x1 + x2 + ...原创 2019-12-04 14:56:00 · 2682 阅读 · 0 评论 -
49 leetcode - Maximum Subarray
Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.原创 2016-12-21 12:41:35 · 191 阅读 · 0 评论 -
56 leetcode - Jump Game
Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.原创 2016-12-25 10:28:40 · 255 阅读 · 0 评论 -
57 leetcode - Jump Game II
Jump Game IIGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.原创 2016-12-25 19:48:12 · 215 阅读 · 0 评论 -
58 leetcode - Plus One
Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.原创 2016-12-25 20:02:17 · 265 阅读 · 0 评论 -
46 leetcode - 如何快速判断一个数是不是2的幂、3的幂、4的幂
快速判断一个数是不是2的幂,3的幂,4的幂.Power of Three,Power of Two,Power of Four原创 2016-12-19 13:58:54 · 2237 阅读 · 0 评论 -
59 leetcode - Add Binary
Add BinaryGiven two binary strings, return their sum (also a binary string).原创 2016-12-26 18:15:45 · 271 阅读 · 0 评论 -
60 leetcode - Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.原创 2016-12-26 18:17:23 · 232 阅读 · 0 评论 -
61 leetcode - Spiral Matrix
Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.原创 2016-12-26 18:18:36 · 234 阅读 · 0 评论 -
45 leetcode - Rotate Function
Rotate FunctionGiven an array of integers A and let n to be its length.原创 2016-12-18 11:34:21 · 236 阅读 · 0 评论 -
44 leetcode - Rotate Array
Rotate ArrayRotate an array of n elements to the right by k steps.原创 2016-12-18 11:32:58 · 198 阅读 · 0 评论 -
54 leetcode - N-Queens
N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.八皇后问题原创 2016-12-23 15:37:31 · 323 阅读 · 1 评论 -
40 leetcode - Search a 2D Matrix
Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.原创 2016-12-15 19:20:58 · 206 阅读 · 0 评论 -
41 leetcode - Search a 2D Matrix II
Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right....原创 2016-12-15 19:23:09 · 232 阅读 · 0 评论 -
50 leetcode - Maximum Product Subarray
Maximum Product Subarray.Find the contiguous subarray within an array (containing at least one number) which has the largest product.原创 2016-12-21 19:18:02 · 250 阅读 · 0 评论 -
51 leetcode - Minimum Size Subarray Sum
Minimum Size Subarray Sum Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.原创 2016-12-21 22:56:07 · 379 阅读 · 0 评论 -
52 leetcode - Multiply Strings
Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.原创 2016-12-22 19:31:05 · 200 阅读 · 0 评论 -
70 leetcode - Single Number I,II,III
leetcode中Single Number I,Single Number II,Single Number III.原创 2017-01-03 10:46:10 · 269 阅读 · 0 评论 -
53 leetcode - Group Anagrams
Group Anagrams.Given an array of strings, group anagrams together.原创 2016-12-23 14:44:50 · 317 阅读 · 0 评论 -
55 leetcode - N-Queens II
N-Queens IINow, instead outputting board configurations, return the total number of distinct solutions.八皇后问题原创 2016-12-23 15:44:53 · 438 阅读 · 0 评论 -
62 leetcode - Spiral Matrix II
Spiral Matrix IIGiven an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.原创 2016-12-26 18:19:15 · 170 阅读 · 0 评论 -
65 leetcode - Climbing Stairs
Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?原创 2016-12-27 20:44:03 · 209 阅读 · 0 评论 -
79 leetcode - Merge Sorted Array
leetcode Merge Sorted ArrayGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.原创 2017-01-07 17:11:48 · 224 阅读 · 0 评论 -
47 leetcode - Combination Sum III
Combination Sum IIIFind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.原创 2016-12-20 21:52:22 · 296 阅读 · 0 评论 -
48 leetcode - Combination Sum IV
Combination Sum IVGiven an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.原创 2016-12-20 21:57:22 · 285 阅读 · 0 评论 -
80 leetcode - Subsets II
Subsets IIGiven a collection of integers that might contain duplicates, nums, return all possible subsets.原创 2017-01-09 10:57:55 · 193 阅读 · 0 评论 -
81 leetcode - Decode Ways
Decode Ways原创 2017-01-09 15:06:01 · 225 阅读 · 0 评论 -
68 leetcode - Minimum Path Sum
Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.原创 2017-01-01 09:10:59 · 332 阅读 · 0 评论 -
69 leetcode - Simplify Path
Simplify PathGiven an absolute path for a file (Unix-style), simplify it.原创 2017-01-01 11:35:19 · 222 阅读 · 0 评论 -
64 leetcode - Unique Paths II
Unique Paths IINow consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.原创 2016-12-27 20:42:57 · 184 阅读 · 0 评论 -
78 leetcode - Remove Duplicates from Sorted List
leetcode,Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear only once.原创 2017-01-06 16:59:14 · 199 阅读 · 0 评论 -
77 leetcode - Remove Duplicates from Sorted List II
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.原创 2017-01-06 16:57:19 · 272 阅读 · 0 评论 -
63 leetcode - Unique Paths
Unique PathsA robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach th原创 2016-12-27 20:41:17 · 203 阅读 · 0 评论 -
71 leetcode - Permutation Sequence
Permutation Sequence.The set [1,2,3,…,n] contains a total of n! unique permutations.原创 2017-01-04 21:33:11 · 209 阅读 · 0 评论 -
72 leetcode - Sqrt(x)
leetcode Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x.原创 2017-01-04 22:20:30 · 211 阅读 · 0 评论 -
73 leetcode - Set Matrix Zeroes
leetcode - Set Matrix Zeroes.Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.原创 2017-01-05 19:37:27 · 290 阅读 · 0 评论 -
74 leetcode - Sort Colors
leetcode Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.原创 2017-01-05 19:39:21 · 216 阅读 · 0 评论 -
75 leetcode - Word Search
leetcode Word Search.Given a 2D board and a word, find if the word exists in the grid.原创 2017-01-05 19:41:49 · 257 阅读 · 0 评论 -
67 leetcode - First Missing Positive
First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.原创 2016-12-28 19:59:51 · 423 阅读 · 0 评论