![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数学之美
文章平均质量分 65
白熊花田
这个作者很懒,什么都没留下…
展开
-
LeetCode[Math]----Excel Sheet Column Title----Excel Sheet Column Number
Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27原创 2016-04-22 16:28:27 · 1525 阅读 · 0 评论 -
LeetCode----Binary Search Tree Iterator
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest原创 2015-10-29 23:30:32 · 597 阅读 · 0 评论 -
LeetCode----Implement Queue using Stacks
Implement Queue using StacksImplement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.pe原创 2015-10-29 21:15:19 · 584 阅读 · 0 评论 -
LeetCode----Binary Tree Preorder Traversal
Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3ret原创 2015-10-29 20:54:08 · 535 阅读 · 0 评论 -
LeetCode----Insertion Sort List
Insertion Sort ListSort a linked list using insertion sort.原题链接为:https://leetcode.com/problems/insertion-sort-list分析:使用插入排序对链表进行排序。可以新建一个带头节点的有序链表,每次从原链表中选择一个节点,插入到带头节点的链表中。C++代码:...原创 2015-11-14 17:16:52 · 606 阅读 · 0 评论 -
LeetCode----Combination Sum II
Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only b原创 2015-10-10 17:55:54 · 520 阅读 · 0 评论 -
LeetCode----Sort List
Sort ListSort a linked list in O(n log n) time using constant space complexity.分析:给链表排序,要求O(nlogn)的时间,O(1)的空间。链表不是数组,给它排序不能像数组一样可以通过各种下标操作。能够想到的方法也就是(1)通过新建一个有序链表,每次从原来链表中选择一个元素到新的有序原创 2015-11-14 15:42:18 · 547 阅读 · 0 评论 -
LeetCode----Gray Code
Gray CodeThe 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 number of bits in the code, print原创 2015-10-14 16:11:12 · 520 阅读 · 0 评论 -
LeetCode----Longest Valid Parentheses
Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest va原创 2015-09-24 20:08:02 · 561 阅读 · 0 评论 -
LeetCode----Power of Two
Power of TwoGiven an integer, write a function to determine if it is a power of two.Credits:Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.原创 2015-10-14 16:56:49 · 556 阅读 · 0 评论 -
LeetCode----Perfect Squares
Perfect SquaresGiven 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原创 2015-09-23 19:22:45 · 1118 阅读 · 0 评论 -
LeetCode----Add Digits
Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 =原创 2015-10-12 20:32:45 · 1021 阅读 · 0 评论 -
LeetCode----Word Search
Word SearchGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizon原创 2015-10-09 16:47:17 · 537 阅读 · 0 评论 -
LeetCode----Single Number
Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement原创 2015-10-12 22:23:45 · 546 阅读 · 0 评论 -
LeetCode----Combinations
CombinationsGiven 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],原创 2015-10-12 18:34:15 · 1531 阅读 · 0 评论 -
LeetCode----Happy Number
Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by th原创 2015-11-11 10:21:52 · 640 阅读 · 0 评论 -
LeetCode----Permutation Sequence
Permutation SequenceThe 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原创 2015-10-11 20:01:07 · 534 阅读 · 0 评论 -
LeetCode----Single NumberII
Single Number IIGiven an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you原创 2015-10-15 11:08:58 · 511 阅读 · 0 评论 -
LeetCode----Binary Tree Postorder Traversal
Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3r原创 2015-10-30 12:04:04 · 613 阅读 · 0 评论 -
LeetCode----Add and Search Word - Data structure design
Binary Tree Right Side ViewGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given原创 2015-10-30 18:02:16 · 624 阅读 · 0 评论 -
LeetCode----Search for a Range
Search for a Range Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).原创 2015-09-04 23:13:15 · 583 阅读 · 0 评论 -
LeetCode----Two Sum
Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to原创 2015-09-25 09:00:58 · 1494 阅读 · 0 评论 -
LeetCode----Reverse Linked List II
Reverse Linked List IIReverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.原创 2015-09-25 17:15:53 · 520 阅读 · 0 评论 -
LeetCode----Reverse Linked List
Reverse Linked ListReverse a singly linked list.代码:# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next原创 2015-09-25 17:09:30 · 531 阅读 · 0 评论 -
LeetCode[Math]----Pow(x, n)
Pow(x, n)Implement pow(x, n).分析:实现pow函数,注意,这里的n是int类型,比较简单,使用二分法。代码:class Solution(object): def myPow(self, x, n): """ :type x: float :type n: int原创 2015-10-23 16:00:56 · 762 阅读 · 0 评论 -
从最大似然到EM算法浅解
从最大似然到EM算法浅解zouxy09@qq.comhttp://blog.csdn.net/zouxy09 机器学习十大算法之一:EM算法。能评得上十大之一,让人听起来觉得挺NB的。什么是NB啊,我们一般说某个人很NB,是因为他能解决一些别人解决不了的问题。神为什么是神,因为神能做很多人做不了的事。那么EM算法能解决什么问题呢?或者说EM算法是因为什转载 2016-04-27 10:15:52 · 741 阅读 · 0 评论 -
数学之美之TF-IDF算法
数学之美之TF-IDF算法By 白熊花田(http://blog.csdn.net/whiterbear) 转载需注明出处,谢谢。吴军博士在《数学之美》一书中提到如何使用TF-IDF算法进行确定网页和查询的相关性判断。我在这里给出自己学习的笔记。相关名称:TF-IDF(term frequency–inversedocum原创 2015-05-08 18:59:44 · 5109 阅读 · 1 评论 -
LeetCode----Isomorphic Strings
Isomorphic StringsGiven two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character原创 2015-12-02 09:05:44 · 820 阅读 · 0 评论 -
LeetCode----Find the Duplicate Number
Find the Duplicate NumberGiven an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there原创 2015-11-02 11:11:01 · 820 阅读 · 0 评论 -
LeetCode----Maximum Depth of Binary Tree
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2015-10-31 22:47:38 · 652 阅读 · 0 评论 -
LeetCode----Word Pattern
Word PatternGiven a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-原创 2015-11-01 20:01:57 · 757 阅读 · 0 评论 -
LeetCode----Move Zeroes
Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12]原创 2015-11-01 23:21:05 · 738 阅读 · 0 评论 -
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.For example,Given 1->2原创 2015-11-01 10:55:44 · 813 阅读 · 0 评论 -
LeetCode----Partition List
Partition ListGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order o原创 2015-11-01 16:29:56 · 693 阅读 · 0 评论 -
LeetCode----Linked List Cycle
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?分析:判断一个链表是否含有环。使用弗洛伊德循环检测法。时间复杂度为O(n)。算法详解如下:原创 2015-10-31 11:26:41 · 758 阅读 · 0 评论 -
LeetCode----Swap Nodes in Pairs
Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should原创 2015-10-30 22:22:18 · 607 阅读 · 0 评论 -
LeetCode----Subsets II
Subsets IIGiven a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set m原创 2015-10-11 14:24:16 · 599 阅读 · 0 评论 -
LeetCode----Combination Sum
Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chos原创 2015-10-10 17:48:28 · 641 阅读 · 0 评论 -
数组循环移位
数组循环移位要求:设计一个算法,把一个含有N个元素的数组循环右移K位,要求时间复杂段为O(N),且只允许使用两个附加变量。分析:在翻阅《编程之美》时看到了这道题,虽然书上已经给了一个完善简便的解法,但是自己却想到了一个时间O(n)空间O(1)的算法。这里先给出书中的算法,再给出我的算法。书中使用的是三次逆序操作。比如要对“abcd1234”右移4位,可以:(1)逆序原创 2015-09-22 10:51:34 · 695 阅读 · 0 评论 -
LeetCode----Merge Sorted Array
Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or原创 2015-09-06 15:30:40 · 686 阅读 · 0 评论