leetcode.etc
tracyliang223
温水煮青蛙 IT纯学渣
展开
-
leetcode:LRU Cache
COPY FROM:http://www.cnblogs.com/x1957/p/3485053.html 做个LRU,算法挺简单的。。。 而且好像用处也挺广的(?),用的比较广的一个cache算法 比如我cache只有4这么大,现在有很多元素1,2,2,4,2,5,3 cache income:1 1 cache转载 2014-04-30 10:42:18 · 755 阅读 · 0 评论 -
leetcode:Generate Parentheses
题目: Generate Parentheses Total Accepted: 11899 Total Submissions: 38480My Submissions Given n pairs of parentheses, write a function to generate all combinations of well-formed par原创 2014-05-23 09:40:56 · 762 阅读 · 0 评论 -
leetcode:ZigZag Conversion
COPY FROM:http://blog.csdn.net/zhouworld16/article/details/14121477 题目要求: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to displ转载 2014-05-22 19:03:51 · 900 阅读 · 0 评论 -
leetcode:median of two sorted arrays
COPY FROM:http://blog.csdn.net/yutianzuijin/article/details/11499917 这是我做的第二个leetcode题目,一开始以为和第一个一样很简单,但是做的过程中才发现这个题目非常难,给人一种“刚上战场就踩上地雷挂掉了”的感觉。后来搜了一下leetcode的难度分布表(leetcode难度及面试频率)才发现,该问题是难度为5的问题转载 2014-04-19 14:00:05 · 743 阅读 · 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 3. Fo原创 2014-04-19 12:29:10 · 801 阅读 · 0 评论 -
leetcode:Reverse digits of an integer
//Reverse digits of an integer. //Example1: x = 123, return 321 //Example2: x = -123, return -321 //Have you thought about this? //Here are some good questions to ask before coding. Bonus points for y原创 2014-04-18 09:54:39 · 941 阅读 · 0 评论 -
leetcode:Sort List
Sort List: Total Accpeptt Sort a linked list in O(n log n) time using constant space complexity.原创 2014-04-16 10:13:55 · 787 阅读 · 0 评论 -
leetcodez:Two Sum
COPY FROM: http://blog.csdn.net/jiadebin890724/article/details/23305449 Two Sum Total Accepted: 16363 Total Submissions: 87273My Submissions Given an array of integers, find two n转载 2014-04-16 12:29:58 · 873 阅读 · 0 评论 -
leetcode:Single Number II
题目: Given 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 implement it wi原创 2014-04-17 18:09:15 · 923 阅读 · 0 评论 -
leetcode:reverseWords
//For example, //Given s = "the sky is blue", //return "blue is sky the".原创 2014-04-16 11:15:57 · 846 阅读 · 0 评论 -
leetcode:Max Points on a Line
第一种方法代码比第二种长:转载 2014-04-16 19:59:37 · 846 阅读 · 0 评论 -
leetcode:Linked List Cycle II
COPY FROM: 比I麻烦点的就是找到循环开始点TAT I只是判断是否循环。要求不使用额外空间(不然hash就可以了 按I的思路,我们又慢指针S和快指针F。。。F走两步,S走一步。。。若有环,必定相遇。 画个图(很丑勿喷 假设在红色凸起的地方相遇了。 F走的路程应该是S的两倍 S = x + y F = x + y + z +转载 2014-07-10 14:23:43 · 810 阅读 · 0 评论