
leetcode
陆业聪
腾讯高级客户端工程师。这里有大前端的经验分享和技术干货。关注公众号“陆业聪”,获取最新技术文章。
展开
-
LeetCode:(LRU) cache
import java.util.LinkedHashMap;import java.util.Map;/** * Design and implement a data structure for Least Recently Used (LRU) cache. * It should support the following operations: get and set.原创 2015-01-13 16:12:05 · 568 阅读 · 0 评论 -
LeetCode:Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updated原创 2015-01-22 11:32:14 · 681 阅读 · 0 评论 -
LeetCode:Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.public class Solutio原创 2015-01-22 11:23:55 · 514 阅读 · 0 评论 -
LeetCode:Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is def原创 2015-01-21 18:12:41 · 467 阅读 · 0 评论 -
LeetCode:Excel Sheet Column Title
Given 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 -> AA 28 -> AB Credits:S原创 2015-01-20 17:10:24 · 555 阅读 · 0 评论 -
LeetCode:Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the fol转载 2015-01-19 15:32:27 · 471 阅读 · 0 评论 -
ZigZag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L转载 2015-01-16 17:13:18 · 543 阅读 · 0 评论 -
LeetCode:Two Sum
Given 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 the target, w转载 2015-01-15 12:58:58 · 519 阅读 · 0 评论 -
LeetCode:Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solution is t转载 2015-01-13 17:07:00 · 414 阅读 · 0 评论 -
LeetCode:Single Number
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 using e原创 2015-01-13 16:18:05 · 439 阅读 · 0 评论 -
LeetCode : Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be原创 2015-01-13 18:00:06 · 563 阅读 · 0 评论 -
LeetCode: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 a原创 2015-01-22 21:09:20 · 480 阅读 · 0 评论