摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2014-06-27 14:03 穆穆兔兔 阅读(245) 评论(0) 推荐(0)
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2014-06-26 18:02 穆穆兔兔 阅读(200) 评论(0) 推荐(0)
摘要: Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Fo... 阅读全文
posted @ 2014-06-26 14:36 穆穆兔兔 阅读(206) 评论(0) 推荐(0)
摘要: Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on... 阅读全文
posted @ 2014-06-25 17:11 穆穆兔兔 阅读(177) 评论(0) 推荐(0)
摘要: Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with ... 阅读全文
posted @ 2014-06-25 16:45 穆穆兔兔 阅读(180) 评论(0) 推荐(0)
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-06-25 15:58 穆穆兔兔 阅读(188) 评论(0) 推荐(0)
摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie... 阅读全文
posted @ 2014-06-24 17:54 穆穆兔兔 阅读(242) 评论(0) 推荐(0)
摘要: http://stackoverflow.com/questions/200384/constant-amortized-time分摊常量时间:Amortised time explained in simple terms:If you do an operation say a million ... 阅读全文
posted @ 2014-06-24 16:58 穆穆兔兔 阅读(1088) 评论(0) 推荐(1)
摘要: 当所给问题是从n个元素的集合S中找出满足某种性质的子集时,解空间为子集树。例如:0-1背包问题当所给问题是从n个元素的集合S中找出满足某种性质的排列时,解空间为排列树。例如:旅行售货员问题回溯法搜索子集树算法描述为:void backtrack(int t){ if(t>n) output... 阅读全文
posted @ 2014-06-24 11:29 穆穆兔兔 阅读(4582) 评论(0) 推荐(2)
摘要: 概念全排列的生成算法有很多种,有递归遍例,也有循环移位法等等。C++/STL中定义的next_permutation和prev_permutation函数则是非常灵活且高效的一种方法,它被广泛的应用于为指定序列生成不同的排列。本文将详细的介绍prev_permutation函数的内部算法。按照STL... 阅读全文
posted @ 2014-06-20 13:20 穆穆兔兔 阅读(357) 评论(0) 推荐(0)