
leetcode
世纪殇
一个不断保持前进的程序员,目前潜心在数据分析和中等网站架构设计中
展开
-
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. For原创 2015-07-01 14:47:58 · 452 阅读 · 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-07-01 09:49:00 · 440 阅读 · 0 评论 -
判断回文数字
给定一个数字,判断该数字是不是回文数字,也即121 6556均为回文数字 class Solution { private: int num; public: int get_max(int len) { len--; long long nAverage=1; while(len--) { nAverage*=2; } nAverage--; retur原创 2015-07-08 21:26:28 · 474 阅读 · 0 评论 -
atoi
class Solution { public: int myAtoi(string str) { long long n = 0; int flag = 0; for (int i = 0; i < str.length(); i++){ char ch = str.at(i); if (flag == 0 && ch == ' '){ continue;原创 2015-07-08 21:51:03 · 434 阅读 · 0 评论 -
Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 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)). 问题描述:给定两个有序数组,从这两个有序数组中找到中值原创 2015-07-01 22:09:42 · 432 阅读 · 0 评论 -
Longest Palindromic Substring
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. 问题描述:给定一个字符串,在这个字符串中寻找最原创 2015-07-03 11:12:39 · 123 阅读 · 0 评论 -
Reverse digits of an integer.
Example1: x = 123, return 321 Example2: x = -123, return -321 挺简单的一个题目,只需要分情况讨论即可,因为一个int型数据可能是正数可能是负数,也可能为0,当然还有一种很重要的情况就是溢出,当实参大于int的最大值的情况下的处理,直接返回0即可 class Solution { public: int reverse(int x原创 2015-07-06 20:31:27 · 1287 阅读 · 0 评论 -
Lowest Common Ancestor of a Binary Tree
在一个二叉树中指定两个节点,并在这两个节点中寻找他们的最小父节点!!! struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; struct TreeSeal { TreeSeal *left; Tree原创 2015-07-14 11:50:50 · 385 阅读 · 0 评论