题目链接:https://leetcode.com/problems/remove-element/
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. ...
分类:
其他好文 时间:
2015-07-19 18:03:33
阅读次数:
92
sqrt(x) : https://leetcode.com/problems/sqrtx/Implement int sqrt(int x).
Compute and return the square root of x.解析:
容易想到的是用二分法去试,但收敛速度太慢,不能满足时间要求。
我们知道求根公式,牛顿迭代法 点击查看维基百科
首先,选择一个接近函数f(x)零点的x_0,计...
分类:
其他好文 时间:
2015-07-19 10:22:55
阅读次数:
166
Intersection of Two Linked Lists : https://leetcode.com/problems/intersection-of-two-linked-lists/Write a program to find the node at which the intersection of two singly linked lists begins.For exampl...
分类:
其他好文 时间:
2015-07-19 10:22:22
阅读次数:
140
Power of Two : https://leetcode.com/problems/power-of-two/
Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的幂?
当无从下手时,可以根据例子找出规律。对于1,2,4,8,16它们的二进制表示分别是:
1: (1)
2:...
分类:
其他好文 时间:
2015-07-19 10:22:13
阅读次数:
210
题目链接:https://leetcode.com/problems/swap-nodes-in-pairs
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as...
分类:
其他好文 时间:
2015-07-19 10:15:56
阅读次数:
93
题目链接:https://leetcode.com/problems/merge-k-sorted-lists/
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
/**
* Definition for singly-l...
分类:
其他好文 时间:
2015-07-19 10:12:41
阅读次数:
114
https://leetcode.com/problems/combination-sum/ 1 class Solution { 2 public: 3 void getResult(vector>& res,vector& path,int target,int index,int su...
分类:
其他好文 时间:
2015-07-18 19:50:42
阅读次数:
102
Pow(x, n) : https://leetcode.com/problems/powx-n/Implement pow(x, n).解析:
同剑指offer: 数值的整数次方 | Power本题考查的关键点有:
double 不能使用“==”
0 不能取负数次幂
任何数的 0 次幂为 1
1的任何次幂为1
-1的偶数次幂为1,奇数次幂为-1
如何快速的计算一个数的整数次幂
注意: 关于基数...
分类:
其他好文 时间:
2015-07-18 18:40:55
阅读次数:
126
https://leetcode.com/problems/divide-two-integers/需要注意的,int类型的数据,正数最大和负数最小可以表示到:2147483647-2147483648正数最大的二进制码为:011111111......1111,负数最小的二进制码为:1000000...
分类:
其他好文 时间:
2015-07-18 18:31:53
阅读次数:
141
Reverse Nodes in k-Group : https://leetcode.com/problems/reverse-nodes-in-k-group/Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes...
分类:
其他好文 时间:
2015-07-18 17:04:26
阅读次数:
100