Algorithm
文章平均质量分 56
霄月林语
这个作者很懒,什么都没留下…
展开
-
[LeetCode] LRU Cache
题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of th原创 2014-08-02 21:58:35 · 294 阅读 · 0 评论 -
[LeetCode] Multiply Strings
题目:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.题解:原创 2014-07-24 00:27:55 · 332 阅读 · 0 评论 -
[LeetCode] Swap Nodes in Pairs
题目:Given 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 use only constant原创 2014-07-26 00:33:55 · 307 阅读 · 0 评论 -
钢条切割
题目:给定一段长度为n英寸的钢条原创 2014-07-26 21:10:52 · 483 阅读 · 0 评论 -
[LeetCode] Populating Next Right Pointers in Each Node
题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right原创 2014-07-25 22:20:27 · 233 阅读 · 0 评论 -
[LeetCode] Climbing Stairs
题目: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?题解:可以由递推关系得出原创 2014-07-25 23:36:54 · 279 阅读 · 0 评论 -
[LeetCode] Palindrome Number
class Solution {public: bool isPalindrome(int x) { if( x < 0 ) return false; int count = 1; int p = x; while( p/10 != 0){ count++; p /= 10; } for(int i = 0; i < count/原创 2014-05-26 14:30:44 · 293 阅读 · 0 评论 -
[LeetCode] Single Number
Title:Given 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 it without u原创 2014-03-13 21:23:23 · 305 阅读 · 0 评论 -
[LeetCode] Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is原创 2014-07-24 00:36:49 · 364 阅读 · 0 评论 -
Latent Dirichlet Allocation
最近一直在看LDA,等看的明白了,整理一篇文档出来。虽然现在有很多关于LDA的深入浅出的文章,但是觉得还是自己整理的比较易于自己理解原创 2014-03-19 08:55:41 · 457 阅读 · 0 评论 -
正整数序列 (Help is needed for Dexter, UVa 11384)
给定正整数n,你的任务是用最少的操作次数把序列1, 2, 3 ... n 中的所有数都变为0。 每次操作可以从序列中选择一个或多个整数,同时减去一个相同的正整数。比如,1,2,3可以把2和3同时减小2,得到1,0,1.【输入格式】输入包含多组数据。每组仅一行,为正整数n(n 【输出格式】对于每组数据,输出最少操作次数。【题解】每次减去(n/2+1)。这样剩下的一部分转载 2014-01-23 20:19:26 · 611 阅读 · 0 评论 -
[LeetCode] Sqrt(x)
题目:Implement int sqrt(int x).Compute and return the square root of x.原创 2014-07-28 18:45:16 · 342 阅读 · 0 评论