LintCode有大部分题目来自LeetCode,但LeetCode比较卡,下面以LintCode为平台,简单介绍我AC的几个题目,并由此引出一些算法基础。 1)两数之和(two-sum) 题目编 ...
LintCode有大部分题目来自LeetCode,但LeetCode比较卡,下面以LintCode为平台,简单介绍我AC的几个题目,并由此引出一些算法基础。 1)两数之和(two-sum) 题目编 ...
描述 设计一种方法,通过给重复字符计数来进行基本的字符串压缩。 例如,字符串 aabcccccaaa 可压缩为 a2b1c5a3 。而如果压缩后的字符 ...
Given a sequence of integers, find the longest increasing subsequence (LIS). You code should ret ...
There are n coins with different value in a line. Two players take turns to take one or tw ...
For an array A, if i < j, and A [i] > A [j], called (A [i], A [j]) is a reverse pair.return ...
Given an array of integers and a number k, find k non-overlapping subarrays which have the largest s ...
Reverse digits of an integer. Returns 0 when the reversed integer overflows (signed 32-bit int ...
自己写的代码有几个比较大的用例一直过不去,网上的代码大部分有问题,思路是先将链表置空表,再将链表中的元素循环插入到指定位置。 下面是一份正确的代码,但是是带头节点的链表: void ...
Given an integer array nums with all positive numbers and no duplicates, find the number o ...
主要利用快排递归划分的思想,可以在期望复杂度为O(n)的条件下求第k大数。快排的期望复杂度为O(nlogn),因为快排会递归处理划分的两边,而求第k大数则只需要处理划分的一边,其期望复杂 ...