leetcode
tianyi1991
这个作者很懒,什么都没留下…
展开
-
最长回文字串的提取(相当精简!)
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. class Solution转载 2015-06-03 21:46:28 · 373 阅读 · 0 评论 -
3.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原创 2015-06-03 14:07:38 · 411 阅读 · 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, where i原创 2015-05-31 22:19:36 · 340 阅读 · 0 评论 -
add two numbers
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 link原创 2015-06-03 09:53:03 · 543 阅读 · 0 评论 -
最长回文字串的提取
#include #include using namespace std; class Solution { public: string longestPalindrome(string s) { if (s.empty() || s.size() == 1) return s; int minStart = 0; int maxlength = 0; in原创 2015-06-30 16:07:36 · 488 阅读 · 1 评论 -
leetcode(6)-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 N A P L S I原创 2015-07-01 19:33:15 · 343 阅读 · 0 评论 -
按层次方式打印二叉树
给定一个二叉树,以层次方式打印各层元素,如下。用到广度优先遍历。以广度优先,就是说一层层地打印,这样,先入的就先打印,所以用到的数据据结构是队列。而深度优先,则是先遍历完一个分支才进行第二个分支,用的是栈结构。 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left原创 2015-07-28 10:58:31 · 2293 阅读 · 0 评论 -
leetcode:Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.给定一个单向链表,判断其是否为回文。 Follow up: Could you do it in O(n) time and O(1) space? ----------------------------------------------------------原创 2015-07-23 19:27:20 · 443 阅读 · 0 评论