
oj.leetcode.com
文章平均质量分 79
type_q
这个作者很懒,什么都没留下…
展开
-
Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu原创 2014-03-11 15:16:45 · 552 阅读 · 0 评论 -
求数列的下一个排列
class Solution {bool check(vector num){for(int i = 0; i {if(num[i] {return true;}}return false;}void adj(vector &num){int i = num.size() - 1;while(num[i - 1] >= num[i])原创 2014-04-18 22:09:06 · 557 阅读 · 0 评论 -
3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c原创 2014-04-19 13:12:45 · 449 阅读 · 0 评论 -
3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2014-04-18 22:23:43 · 445 阅读 · 0 评论 -
Sum Root to Leaf Numbers
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 tota原创 2014-03-20 20:14:29 · 472 阅读 · 0 评论 -
Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur原创 2014-03-17 22:45:16 · 453 阅读 · 0 评论 -
Minimum Window Substring
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 = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN原创 2014-04-14 14:13:33 · 493 阅读 · 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 S I原创 2014-03-15 16:23:29 · 459 阅读 · 0 评论 -
Single Number I & II
Single NumberGiven 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 i原创 2014-03-16 10:23:01 · 442 阅读 · 0 评论 -
Longest Substring Without Repeating Characters
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. Fo原创 2014-03-10 15:05:53 · 519 阅读 · 0 评论 -
Median of Two Sorted Arrays
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)).这也算是一道经典题目了吧。背景应该是并归排序。class Solu原创 2014-03-14 23:54:44 · 443 阅读 · 0 评论 -
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, whe原创 2014-03-14 23:23:25 · 466 阅读 · 0 评论 -
Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum原创 2014-03-13 15:16:38 · 447 阅读 · 0 评论 -
Binary Tree Maximum Path Sum
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.原创 2014-03-12 19:35:03 · 439 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node I & II
Populating Next Right Pointers in Each Node Total Accepted: 10797 Total Submissions: 31598My SubmissionsGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; Tre原创 2014-03-26 16:47:37 · 568 阅读 · 0 评论