本博客rss订阅地址: http://feed.cnblogs.com/blog/u/147990/rss

随笔分类 -  LeetCode

1 2 3 4 5 ··· 7 下一页
摘要:题目链接Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". 1 class Solution { 2 publ... 阅读全文
posted @ 2014-09-22 19:59 tenos 阅读(1180) 评论(0) 推荐(1) 编辑
摘要:题目链接 Write a function to find the longest common prefix string amongst an array of strings. 题目的意思说的不是很清楚,开始理解成了求任意两个字符串的前缀中的最长者。但是本题的意思是求所有字符串的最长公共前缀,即数组的所有字符串都包含这个前缀。 算法1:逐个字符比较,时间复杂度为O(N*L),N是... 阅读全文
posted @ 2014-07-20 16:11 tenos 阅读(11515) 评论(0) 推荐(0) 编辑
摘要:Container With Most Water 题目链接 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is... 阅读全文
posted @ 2014-06-28 00:18 tenos 阅读(5070) 评论(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 conca... 阅读全文
posted @ 2014-06-24 22:33 tenos 阅读(2549) 评论(0) 推荐(0) 编辑
摘要:题目链接Implement pow(x, n).主要利用x^2n = (x^n)*(x^n), x^2n+1 = (x^n)*(x^n)*x注意n是负数,对其取反时,可能会溢出其实0^0(都是整数)是未定义的,因为0^0 = 0^1 / 0^1 = 0 / 0, 0作为除数是未定义的,可以参考维基百... 阅读全文
posted @ 2014-06-22 20:11 tenos 阅读(1022) 评论(0) 推荐(0) 编辑
摘要:Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C u... 阅读全文
posted @ 2014-06-22 15:49 tenos 阅读(1589) 评论(0) 推荐(1) 编辑
摘要:N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, retu... 阅读全文
posted @ 2014-06-21 23:02 tenos 阅读(13863) 评论(0) 推荐(0) 编辑
摘要:Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are... 阅读全文
posted @ 2014-06-21 00:41 tenos 阅读(7432) 评论(3) 推荐(0) 编辑
摘要:题目链接 Divide two integers without using multiplication, division and mod operator. 最直观的方法是,用被除数逐个的减去除数,直到被除数小于0。这样做会超时。 本文地址 那么如果每次不仅仅减去1个除数,计算速度就会增加,但是题目不能使用乘法,因此不能减去k*除数,我们可以对除数进行... 阅读全文
posted @ 2014-06-18 20:58 tenos 阅读(5282) 评论(1) 推荐(0) 编辑
摘要:题目链接 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as i... 阅读全文
posted @ 2014-06-18 14:04 tenos 阅读(993) 评论(0) 推荐(0) 编辑
摘要:题目链接 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 space... 阅读全文
posted @ 2014-06-17 22:38 tenos 阅读(683) 评论(0) 推荐(0) 编辑
摘要:题目链接 Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. ... 阅读全文
posted @ 2014-06-17 22:13 tenos 阅读(672) 评论(0) 推荐(0) 编辑
摘要:首先简单介绍一下罗马数字,一下摘自维基百科罗马数字共有7个,即I(1)、V(5)、X(10)、L(50)、C(100)、D(500)和M(1000)。按照下述的规则可以表示任意正整数。需要注意的是罗马数字中没有“0”,与进位制无关。一般认为罗马数字只用来记数,而不作演算。重复数次:一个罗马数字重复几... 阅读全文
posted @ 2014-06-17 21:17 tenos 阅读(5465) 评论(0) 推荐(2) 编辑
摘要:题目链接Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((... 阅读全文
posted @ 2014-06-08 18:52 tenos 阅读(2046) 评论(0) 推荐(0) 编辑
摘要:题目链接Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the corr... 阅读全文
posted @ 2014-06-08 16:39 tenos 阅读(594) 评论(0) 推荐(0) 编辑
摘要:题目链接The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off a... 阅读全文
posted @ 2014-06-08 16:12 tenos 阅读(7382) 评论(0) 推荐(3) 编辑
摘要:题目链接 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or righ... 阅读全文
posted @ 2014-06-07 15:00 tenos 阅读(3747) 评论(0) 推荐(0) 编辑
摘要:Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following ... 阅读全文
posted @ 2014-06-07 14:17 tenos 阅读(1699) 评论(0) 推荐(1) 编辑
摘要:题目链接Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the tele... 阅读全文
posted @ 2014-06-05 22:17 tenos 阅读(3724) 评论(0) 推荐(1) 编辑
摘要:题目链接Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the... 阅读全文
posted @ 2014-06-05 21:00 tenos 阅读(1486) 评论(1) 推荐(1) 编辑

1 2 3 4 5 ··· 7 下一页

本博客rss订阅地址: http://feed.cnblogs.com/blog/u/147990/rss

公益页面-寻找遗失儿童