Python
yufengsong09
热爱技术,热爱生活
展开
-
LeetCode---69. Sqrt(x)---Python实现
Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation: Th原创 2018-01-22 15:33:58 · 742 阅读 · 0 评论 -
407. Trapping Rain Water II(python shixian)
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.The above elevation map is represented by array [0...原创 2018-05-28 20:31:14 · 292 阅读 · 0 评论 -
机器学习实战(1) ——K-近邻算法(python实现)
这是学习机器学习算法实战这本书时,写的代码实战。让自己对各个算法有更直观的了解,不能一直不写啊。不管简单还是不简单都亲自一行一行的敲一遍啊。具体的源码和和数据链接:https://pan.baidu.com/s/1G2S2pb5gfBnxGNNTFgTkEA 密码:fov0# -*- coding: utf-8 -*-# author: Yufeng Songfrom numpy imp...原创 2018-03-15 21:06:06 · 290 阅读 · 0 评论 -
LeetCode 78. Subsets--Python实现
Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1...原创 2018-01-29 17:24:41 · 595 阅读 · 0 评论 -
LeetCode 77. Combinations--python实现
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2018-01-29 11:53:27 · 313 阅读 · 0 评论 -
LeetCode 76. Minimum Window Substring--Python实现
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN原创 2018-01-29 01:45:09 · 259 阅读 · 0 评论 -
LeetCode 65. Valid Number--Python实现
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo原创 2018-01-16 15:55:17 · 569 阅读 · 0 评论 -
LeetCode 63. Unique Paths II--Python实现
Follow up for "Unique Paths":Now 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原创 2018-01-16 15:01:22 · 263 阅读 · 0 评论 -
LeetCode 64. Minimum Path Sum---Python实现
Given 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.Note: You can only move either down or right at原创 2018-01-16 15:13:29 · 216 阅读 · 0 评论 -
LeetCode 62.Unique Paths---Python实现
A 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 the原创 2018-01-16 14:48:40 · 789 阅读 · 0 评论 -
LeetCode 61. Rotate List---Python实现
Given a list, rotate the list to the right by k places, where k is non-negative.Example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.本题关键在于构建一个循环链表,注意k要对链表长度取余。# Defi原创 2018-01-16 14:33:23 · 153 阅读 · 0 评论 -
LeetCode 72. Edit Distance-----Python实现
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2018-01-24 00:18:53 · 269 阅读 · 0 评论 -
LeetCode 70 Climbing Stairs--Python实现
You 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?Note: Given n will be a positive原创 2018-01-22 16:36:58 · 213 阅读 · 0 评论 -
牛客网合唱团
n = 3arr = [7,4,7]K,D = 2,50fm = [([0] * n) for i in range(K)] # k*dfn = [([0] * n) for i in range(K)] # k*dres = 0# for i in range(n):# fm[0][i] = arr[i]# fn[0][i] = arr[i]## fo...原创 2018-11-07 09:31:23 · 273 阅读 · 0 评论