算法
文章平均质量分 77
fssssssss
nju
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
将一个n元素的数组平均分为m分,是每组和相等,求最大m
网上流行的一道题目,题目如下。最终利用穷取法来递归解决的。 一个整数数组,长度为n,将其分为m 份,使各份的和相等,求m 的最大值 比如{3,2,4,3,6} 可以分成{3,2,4,3,6} m=1; {3,6}{2,4,3} m=2 {3,3}{2,4}{6} m=3 所以m 的最大值为3 using System; using System.Collections.Generic;原创 2012-07-28 17:46:19 · 5475 阅读 · 0 评论 -
8大基础排序
#include using namespace std; //bubble sort void BubbleSort(int *arr,int left,int right) { int temp; for(int i=right-1;i>=left;i--) { for(int j=left;j<=i;j++) { if(arr[j]>arr[j+1]) {原创 2012-07-28 11:57:55 · 637 阅读 · 0 评论 -
(leetcode #10)Regular Expression Matching --递归法
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input st原创 2016-01-28 12:06:20 · 752 阅读 · 0 评论 -
(leetcode #55)Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine i原创 2016-01-31 14:20:16 · 564 阅读 · 0 评论 -
寻找“捣乱分子”对[
转载:http://blog.youkuaiyun.com/wuzhekai1985/article/details/6718256 问题描述:多人排成一个队列,我们认为从低到高是正确的序列,但是总有部分人不遵守秩序。如果说,前面的人比后面的人高(两人身高一样认为是合适的),那么我们就认为这两个人是一对“捣乱分子”,比如说,现在存在一个序列:176, 178, 180, 170, 171转载 2012-07-30 22:10:10 · 1141 阅读 · 0 评论 -
二分查找
using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.IO; using System.Threading; using System.IO.Ports; namespace Program { class Program原创 2012-05-05 15:37:48 · 714 阅读 · 0 评论 -
计算前N个数字钟1的个数(编程之美2.4 1的数目)
#include "point.h" using namespace std; int CalcOneHelp(int); int CalcOne(int); int power(int ,int); int CalcOne(int N)//穷举法,比较傻瓜,思路简单,运算速度慢 { int sum=0; for(int i=1;i<=N;i++) sum+=CalcOneHelp(i)原创 2012-06-16 14:10:38 · 913 阅读 · 0 评论 -
(leetcode 99) Recover Binary Search Tree
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. Could you devis原创 2016-02-01 15:49:25 · 661 阅读 · 0 评论
分享