题目描述
链接地址
解法题目描述Find the nth to last element of a singly linked list. The minimum number of nodes in list is n.
ExampleGiven a List 3->2->1->5->null and n = 2, return node whose value is 1.链接地址http...
分类:
其他好文 时间:
2015-07-06 21:45:46
阅读次数:
122
题目Single Number通过率45.1%难度Medium Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should ...
分类:
其他好文 时间:
2015-07-06 21:21:09
阅读次数:
98
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 nu...
分类:
其他好文 时间:
2015-07-06 21:18:48
阅读次数:
101
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:
其他好文 时间:
2015-07-06 19:44:47
阅读次数:
115
1.显卡信息 dmesg | grep -i vga lspci | grep -i vga//查看显卡信息2.dmidecode | grep -i 'Serial Number'//查看主板信息,查看主板的序列号3.CPU信息 #通过/proc文件系统 cat /proc/cpuinfo...
分类:
系统相关 时间:
2015-07-06 19:43:05
阅读次数:
157
质数(prime number)又称素数,有无限个。一个大于1的自然数,除了1和它本身外,不能被其他自然数(质数)整除,即不再有其他的因数。如下:判断思路:对正整数n,如果用2到之间的所有整数去除,均无法整除,则n为质数。(因为 i*i= n 时, i 时中间的那个因子)#include #incl...
分类:
其他好文 时间:
2015-07-06 19:25:40
阅读次数:
110
结果 = 可以被5整除的数的个数 + 可以被25整除的数的个数 + 可以被125整除的数的个数 + …
参考这篇文章代码如下:class Solution {
public:
int trailingZeroes(int n) {
int result = 0;
int number;
for(; ; ) {...
分类:
其他好文 时间:
2015-07-06 17:59:51
阅读次数:
134
题目:输入数字 n,按顺序打印出从 1 到 最大的 n 位十进制数。比如输入 3 ,则打印出 1、2 、3 一直到最大的3位数即 999。解析:
容易知道不能用 int 等数字类型表示(大数问题)在字符串上模拟数字加法关键点:
1. 如何用字符串表示n位数?
2. 如何实现字符串数的自增操作?
3. 如何打印一个字符串数?
- 申请长度是n+1的字符数组number。 number[...
分类:
其他好文 时间:
2015-07-06 16:11:44
阅读次数:
114
题目:
Given a binary tree, find its minimum depth.
The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
解题:
求根节点到最近的叶子节点之间的距离
用...
分类:
编程语言 时间:
2015-07-06 16:08:36
阅读次数:
152
题目:
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
解题:
求最大深度 和前面一题类似 用递归遍历就...
分类:
编程语言 时间:
2015-07-06 16:06:14
阅读次数:
143