随笔分类 -  leetcode刷题总结

上一页 1 2 3 4 5 6 ··· 9 下一页
https://oj.leetcode.com/
摘要:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文
posted @ 2014-07-25 16:53 SunshineAtNoon 阅读(250) 评论(0) 推荐(0)
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
posted @ 2014-07-25 15:43 SunshineAtNoon 阅读(226) 评论(0) 推荐(0)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on... 阅读全文
posted @ 2014-07-25 12:07 SunshineAtNoon 阅读(193) 评论(0) 推荐(0)
摘要:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
posted @ 2014-07-25 11:15 SunshineAtNoon 阅读(212) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题解,很巧妙的一道题,对于一个0-1矩阵,它的每一行及以上都可以看... 阅读全文
posted @ 2014-07-25 10:42 SunshineAtNoon 阅读(291) 评论(0) 推荐(0)
摘要:You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati... 阅读全文
posted @ 2014-07-24 22:55 SunshineAtNoon 阅读(210) 评论(0) 推荐(0)
摘要:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文
posted @ 2014-07-24 19:52 SunshineAtNoon 阅读(408) 评论(0) 推荐(0)
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2014-07-24 16:44 SunshineAtNoon 阅读(182) 评论(0) 推荐(0)
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-07-24 16:08 SunshineAtNoon 阅读(228) 评论(0) 推荐(0)
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2014-07-24 15:37 SunshineAtNoon 阅读(1412) 评论(0) 推荐(0)
摘要:Divide two integers without using multiplication, division and mod operator.题解:要求不用乘除和取模运算实现两个数的除法。那么用加减法是很自然的选择。不过如果一次只从被除数中剪掉一个除数会TLE。所以我们借助移位运算,依次从... 阅读全文
posted @ 2014-07-24 14:59 SunshineAtNoon 阅读(515) 评论(0) 推荐(0)
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2014-07-24 11:57 SunshineAtNoon 阅读(280) 评论(0) 推荐(0)
摘要:Given 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 "adjace... 阅读全文
posted @ 2014-07-24 10:47 SunshineAtNoon 阅读(202) 评论(0) 推荐(0)
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con... 阅读全文
posted @ 2014-07-24 10:07 SunshineAtNoon 阅读(258) 评论(0) 推荐(0)
摘要:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>true题解:题目不难,就是有点麻烦,要注意的地方很多,总结一下:前面和后面的空格要用s... 阅读全文
posted @ 2014-07-23 19:25 SunshineAtNoon 阅读(199) 评论(0) 推荐(0)
摘要:Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].题解:首先对所有的区间按照s... 阅读全文
posted @ 2014-07-23 17:52 SunshineAtNoon 阅读(175) 评论(0) 推荐(0)
摘要:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.暴力法,从haystack第一个字符开始查找need... 阅读全文
posted @ 2014-07-23 17:20 SunshineAtNoon 阅读(165) 评论(0) 推荐(0)
摘要:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.题解:首先... 阅读全文
posted @ 2014-07-23 16:59 SunshineAtNoon 阅读(162) 评论(0) 推荐(0)
摘要:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.题解:最开始用了最naive的方法,每次在k个链表头中找出最小的元素,插入到新链表中。结果果断TLE了。分析... 阅读全文
posted @ 2014-07-23 16:25 SunshineAtNoon 阅读(330) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2014-07-23 15:27 SunshineAtNoon 阅读(187) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 9 下一页