随笔分类 -  leetcode刷题总结

1 2 3 4 5 ··· 9 下一页
https://oj.leetcode.com/
摘要:题目链接一A,开森~ac代码: 1 class TrieNode { 2 // Initialize your data structure here. 3 char content; 4 boolean isWord; 5 int count; 6 Link... 阅读全文
posted @ 2015-07-14 19:53 SunshineAtNoon 阅读(362) 评论(0) 推荐(0) 编辑
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?题解:如果要原地算法的话,就只能用交换... 阅读全文
posted @ 2015-04-03 16:37 SunshineAtNoon 阅读(291) 评论(0) 推荐(0) 编辑
摘要:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文
posted @ 2015-04-02 16:24 SunshineAtNoon 阅读(213) 评论(0) 推荐(0) 编辑
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文
posted @ 2015-04-01 14:46 SunshineAtNoon 阅读(205) 评论(0) 推荐(0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题解:递归就可以了。Java代码如下: 1 /** 2 * Definition for binary ... 阅读全文
posted @ 2015-03-31 22:24 SunshineAtNoon 阅读(160) 评论(0) 推荐(0) 编辑
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-03-31 16:47 SunshineAtNoon 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2015-03-31 14:29 SunshineAtNoon 阅读(133) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2015-03-31 10:30 SunshineAtNoon 阅读(167) 评论(0) 推荐(0) 编辑
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文
posted @ 2015-03-30 11:06 SunshineAtNoon 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ... 阅读全文
posted @ 2015-03-28 23:08 SunshineAtNoon 阅读(295) 评论(0) 推荐(0) 编辑
摘要:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed... 阅读全文
posted @ 2014-07-27 11:44 SunshineAtNoon 阅读(277) 评论(0) 推荐(0) 编辑
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region... 阅读全文
posted @ 2014-07-26 23:28 SunshineAtNoon 阅读(184) 评论(0) 推荐(0) 编辑
摘要:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should p... 阅读全文
posted @ 2014-07-26 19:39 SunshineAtNoon 阅读(200) 评论(0) 推荐(0) 编辑
摘要:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文
posted @ 2014-07-26 17:12 SunshineAtNoon 阅读(393) 评论(0) 推荐(0) 编辑
摘要:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs... 阅读全文
posted @ 2014-07-26 16:01 SunshineAtNoon 阅读(346) 评论(0) 推荐(0) 编辑
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文
posted @ 2014-07-26 13:57 SunshineAtNoon 阅读(384) 评论(0) 推荐(0) 编辑
摘要:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
posted @ 2014-07-26 11:20 SunshineAtNoon 阅读(175) 评论(0) 推荐(0) 编辑
摘要:Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e... 阅读全文
posted @ 2014-07-26 10:33 SunshineAtNoon 阅读(321) 评论(0) 推荐(0) 编辑
摘要:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文
posted @ 2014-07-25 22:06 SunshineAtNoon 阅读(335) 评论(0) 推荐(0) 编辑
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2014-07-25 17:30 SunshineAtNoon 阅读(175) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 9 下一页
点击右上角即可分享
微信分享提示