LeetCode Intersection of Two Linked Lists 解题报告,求两个链表的第一个公共节点。...
分类:
其他好文 时间:
2014-12-29 01:12:37
阅读次数:
109
【题目】
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 should run in O(n) time and use...
分类:
其他好文 时间:
2014-12-28 22:21:58
阅读次数:
242
题面描述:判定一个数P∈[1,2^63-1]∩N是素数么。
按照朴素的判定素数方法,至少也需要O(P^0.5)的,但这道题就是霸气到连这样的时间复杂度都过不了的地步。
实在是不会做了,就学习了传说中的Miller-Rabin素数判定法。
两个引理:
①费马小定理:
设p为质数,且不满足p|a,
则a^(p-1)=a(mod p).
证:
又一个引理,若n与p互质,且a与p互质,则n...
分类:
其他好文 时间:
2014-12-28 22:17:43
阅读次数:
182
Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You...
分类:
其他好文 时间:
2014-12-28 19:26:42
阅读次数:
108
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5150题目意思:就是直接求素数。 不过 n = 1,也属于答案范围!!只能说,一失足成千古恨啊~~~~~ 1 #include 2 #include 3 #include 4 #include...
分类:
其他好文 时间:
2014-12-27 21:43:41
阅读次数:
258
Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = ...
分类:
其他好文 时间:
2014-12-27 21:40:23
阅读次数:
326
Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible...
分类:
其他好文 时间:
2014-12-27 21:37:15
阅读次数:
192
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ...
分类:
其他好文 时间:
2014-12-27 20:14:16
阅读次数:
214
题目地址:https://oj.leetcode.com/problems/majority-element/题目内容:Given an array of sizen, find the majority element. The majority element is the element th...
分类:
编程语言 时间:
2014-12-27 20:13:16
阅读次数:
140
Longest Palindromic Substring-- HARD 级别Question SolutionGiven a string S, find the longest palindromic substring in S. You may assume that the maximum...
分类:
其他好文 时间:
2014-12-27 20:12:16
阅读次数:
136