自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

大锅八十小锅四十

伪数据挖掘,伪机器学习,通信狗转cs汪一只,https://tinkle1129.github.io/

  • 博客(41)
  • 资源 (2)
  • 收藏
  • 关注

原创 leetcode233. Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example: Given n = 13, Return 6, because digit 1 occurred in the follo

2016-07-17 11:34:11 329

原创 leetcode224. Basic Calculator

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spac

2016-07-17 10:28:01 364

原创 leetcode335. Self Crossing

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] metres to the east and so on. I

2016-07-16 15:45:51 262

原创 leetcode319. Bulb Switcher

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i

2016-07-15 10:16:37 208

原创 leetcode279. Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, re

2016-07-14 18:22:03 287

原创 leetcode365. Water and Jug Problem

You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two ju

2016-07-13 12:37:00 315

原创 leetcode367. Valid Perfect Square

Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Re

2016-07-13 09:43:36 206

原创 leetcode368. Largest Divisible Subset

Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0. If there are multiple solutions, re

2016-07-12 20:47:51 279

原创 leetcode372. Super Pow

Your task is to calculate aba^b mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. Example1: a = 2 b = [3] Result: 8 Examp

2016-07-11 20:36:15 314

原创 leetcode60. Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): “123” “132” “213”

2016-07-10 17:34:37 225

原创 leetcode357. Count Numbers with Unique Digits

Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, e

2016-07-10 16:33:17 261

原创 leetcode223. Rectangle Area

Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.问题关键在于重合的部分怎么计算class Solutio

2016-07-10 12:25:18 220

原创 leetcode69. Sqrt(x)

思路:二分法class Solution(object): def mySqrt(self, x): """ :type x: int :rtype: int """ start=0 end=(x+1)/2 while(start<end):

2016-07-09 10:36:03 227

原创 leetcode50. Pow(x, n)

Implement pow(x, n).xn=xn/2∗xn−n/2x^n=x^{n/2}*x^{n-n/2} 用n>>1来代替n=n/2可以加快运算速度class Solution(object): def myPow(self, x, n): """ :type x: float :type n: int :rtype:

2016-07-09 10:05:30 234

原创 leetcode9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """

2016-07-09 09:49:49 208

原创 leetcode10. Regular Expression Matching

‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be: bool

2016-07-09 09:11:42 305

原创 leetcode72.Edit Distance

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:

2016-07-08 09:16:59 386

原创 leetcode336. Palindrome Pairs

Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Example 1: Given w

2016-07-07 16:22:23 302

原创 leetcode91. Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the tot

2016-07-07 15:10:42 186

原创 leetcode5. Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.manacher算法+详解class Solutio

2016-07-07 13:35:47 216

原创 leetcode151. Reverse Words in a String

Given an input string, reverse the string word by word. For example, Given s = “the sky is blue”, return “blue is sky the”.class Solution(object): def reverseWords(self, s): """

2016-07-07 10:53:32 172

原创 leetcode227. Basic Calculator II

Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should tr

2016-07-06 17:53:21 242

原创 leetcode165. Compare Version Numbers

Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and

2016-07-06 16:41:10 200

原创 leetcode8. String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cas

2016-07-05 10:47:18 186

原创 Leetcode Big Manipulation 解题报告

第一部分leetcode136. Single Number中等难度题意,给一个整数数组,数组中除了一个元素只有一个,其余元素都有两个,求这个只出现一次的元素。要求时间复杂度为O(n),空间复杂度为O(1)思路:利用异或来解决问题,a^a=0,0^b=b解答: class Solution(object): def singleNumber(self, nums): """

2016-07-04 14:10:34 459

原创 leetcode260. Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given num

2016-07-04 08:04:24 197

原创 leetcode201. Bitwise AND of Numbers Range

Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 7], you should return 4.看m,n的前缀 101 111 ->100

2016-07-04 07:39:16 208

原创 leetcode268. Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2.[0,1,2…..,n]的和为(n+0)*(n+1)/2 缺失的

2016-07-02 22:17:58 209

原创 leetcode78. Subsets

Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: [ [3],

2016-07-02 22:02:08 226

原创 leetcode318. Maximum Product of Word Lengths

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette

2016-07-02 17:47:06 223

原创 leetcode342. Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it withou

2016-07-02 16:39:10 244

原创 leetcode112. Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.# Definition for a binary tree node.# class TreeNod

2016-07-02 12:08:34 234

原创 leetcode 338. Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array. Example: For num = 5

2016-07-02 11:51:28 186

原创 leetcode125. Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not

2016-07-02 09:49:08 261

原创 leetcode234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space?反转链表法,将链表后半段原地翻转,再将前半段、后半段依次比较,判断是否相等,时间复杂度O(n),空间复杂度为O(1)满足题目要求。# Definition

2016-07-02 09:12:12 196

原创 leetcode206. Reverse Linked List

Reverse a singly linked list.# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): de

2016-07-02 08:57:58 171

原创 leetcode 172. Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity.思路:要求n!中有多少个0 10的因子有2,5,5即解题关键(因为有5必有2) 2*5=10有一个0 10也有一个0 因此在一个[1,1

2016-07-01 14:22:20 205

原创 leetcode38. Count and Say

The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as “

2016-07-01 13:57:21 237

原创 leetcode 100. Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value.# Definition f

2016-07-01 12:44:42 220

原创 leetocode371 Sum of Two Integers

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3.写一个渣版本 首先判断结果的符号(+,-) 分别有以下几种: -9,7 结果<0 -9,-9 结果<0

2016-07-01 12:26:21 186

统计学习方法笔记(部分算法含matlab代码)

以李航《统计学习方法》为参考,包含自己的理解和部分相关代码~有所不对请大家指出,新手上路,请多指教。

2015-11-17

N-臂老虎机算法(强化学习)

关于强化学习N-臂老虎机算法的理解,包括部分代码和算法流程图

2015-10-11

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除