![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
想落天外
这个作者很懒,什么都没留下…
展开
-
[leetcode] #50 Pow(x,n)
1.题目Implement pow(x, n).也就是要求实现幂的计算。2.蛮力法首先想到的当然是蛮力法,直接乘它个n次:double myPow(double x, int n) { for (int i=0;i<n;i++) { x*=x; } return x; }但显然这题当然没那么简单,直接蛮力后果如下: 看来是有时间复杂度要求限制的,蛮力原创 2015-04-10 00:43:50 · 796 阅读 · 0 评论 -
[leetcode] #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.原创 2015-05-11 20:27:13 · 654 阅读 · 0 评论 -
[leetcode] #143 Reorder List
题目 Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes’ values. For example, Given {1,2,3,4}, re原创 2015-05-10 11:53:59 · 711 阅读 · 0 评论 -
[leetcode] #70 Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 题目大概意思是有n级台阶,每次可以爬2级或者1级,问总共原创 2015-04-09 22:23:12 · 711 阅读 · 0 评论 -
[leetcode] #162 Find Peak Element
从今天起把刷的leetcode题放这里。原创 2015-04-09 15:00:53 · 690 阅读 · 0 评论 -
[leetcode] #4 Median of Two Sorted Array
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)). 题目要求是找到两个已排序的序列A和B的中位数(如果m+原创 2015-04-09 15:20:01 · 743 阅读 · 0 评论 -
[leetcode] #2 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原创 2015-04-15 00:20:44 · 620 阅读 · 0 评论 -
[leetcode] #25 Recover Binary Search Tree
1. 题目 Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty straight forward. Co原创 2015-04-11 00:20:36 · 721 阅读 · 0 评论 -
[leetcode] #129 Sum Root to Leaf Numbers
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原创 2015-04-10 15:49:45 · 663 阅读 · 0 评论 -
二叉树的各种遍历方法
二叉树的遍历方法原创 2015-04-11 16:11:44 · 696 阅读 · 0 评论 -
[leetcode] #41 First Missing Positive
题目 First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm s原创 2015-04-22 09:50:22 · 772 阅读 · 0 评论 -
[leetcode] #89 Gray Code
题目 The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequen原创 2015-05-18 15:49:17 · 691 阅读 · 0 评论