随笔分类 -  LeetCode

摘要:题目: Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3Return 6. 解题思路:最长路... 阅读全文
posted @ 2014-05-27 18:09 mickole 阅读(579) 评论(0) 推荐(0) 编辑
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transactions. Note: You m... 阅读全文
posted @ 2014-05-27 10:29 mickole 阅读(338) 评论(0) 推荐(0) 编辑
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy... 阅读全文
posted @ 2014-05-26 20:25 mickole 阅读(276) 评论(0) 推荐(0) 编辑
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stoc... 阅读全文
posted @ 2014-05-26 20:04 mickole 阅读(371) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 解题思路: 主要有三种: 第一种:... 阅读全文
posted @ 2014-05-01 13:22 mickole 阅读(334) 评论(0) 推荐(0) 编辑
摘要:题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a... 阅读全文
posted @ 2014-04-29 14:07 mickole 阅读(335) 评论(0) 推荐(0) 编辑
摘要:题目: 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.... 阅读全文
posted @ 2014-04-29 12:27 mickole 阅读(609) 评论(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 O(log (m+n)). 解题思路: 这道题,很容易想到的是先排序再直接定位中间那个... 阅读全文
posted @ 2014-04-29 10:26 mickole 阅读(222) 评论(0) 推荐(0) 编辑
摘要:题目: 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, ... 阅读全文
posted @ 2014-04-28 10:53 mickole 阅读(383) 评论(0) 推荐(0) 编辑
摘要:题目: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Each intermediate word m... 阅读全文
posted @ 2014-04-28 09:41 mickole 阅读(419) 评论(0) 推荐(0) 编辑
摘要:题目: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermed... 阅读全文
posted @ 2014-04-27 17:15 mickole 阅读(208) 评论(0) 推荐(0) 编辑
摘要:题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [... 阅读全文
posted @ 2014-04-25 18:50 mickole 阅读(294) 评论(0) 推荐(1) 编辑
摘要:题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total... 阅读全文
posted @ 2014-04-24 23:16 mickole 阅读(244) 评论(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. For example, X X X XX O O XX X O ... 阅读全文
posted @ 2014-04-24 22:28 mickole 阅读(184) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", Ret... 阅读全文
posted @ 2014-04-24 20:48 mickole 阅读(333) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa... 阅读全文
posted @ 2014-04-23 16:54 mickole 阅读(242) 评论(0) 推荐(0) 编辑
摘要:题目:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labele... 阅读全文
posted @ 2014-02-19 08:51 mickole 阅读(281) 评论(0) 推荐(0) 编辑
摘要:题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it co... 阅读全文
posted @ 2014-02-18 22:02 mickole 阅读(305) 评论(0) 推荐(0) 编辑
摘要:题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ... 阅读全文
posted @ 2014-02-18 20:47 mickole 阅读(320) 评论(0) 推荐(0) 编辑
摘要:题目:Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtim... 阅读全文
posted @ 2014-02-18 16:49 mickole 阅读(156) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示