随笔分类 -  Algorithm

上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页

[Jobdu] 题目1384:二维数组中的查找
摘要:题目描述:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为两个整数m和n(1 2 3 int m, n; 4 in... 阅读全文

posted @ 2014-08-11 10:49 Eason Liu 阅读(356) 评论(0) 推荐(0)

[Jobdu] 题目1455:珍惜现在,感恩生活
摘要:题目描述:为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?输入:输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是... 阅读全文

posted @ 2014-08-11 10:30 Eason Liu 阅读(698) 评论(0) 推荐(0)

[Jobdu] 题目1337:寻找最长合法括号序列
摘要:题目描述:给你一个长度为N的,由’(‘和’)’组成的括号序列,你能找出这个序列中最长的合法括号子序列么?合法括号序列的含义便是,在这个序列中,所有的左括号都有唯一的右括号匹配;所有的右括号都有唯一的左括号匹配。例如:((()))()()便是一个长度为10的合法括号序列,而(()))( 则不是。需要你... 阅读全文

posted @ 2014-08-08 15:43 Eason Liu 阅读(3330) 评论(0) 推荐(0)

[Jobdu] 题目1531:货币面值
摘要:题目描述:小虎是游戏中的一个国王,在他管理的国家中发行了很多不同面额的纸币,用这些纸币进行任意的组合可以在游戏中购买各种装备来提升自己。有一天,他突然很想知道这些纸币的组合不能表示的最小面额是多少,请聪明的你来帮助小虎来解决这个财政问题吧。输入:输入包含多个测试用例,每组测试用例的第一行输入一个整数... 阅读全文

posted @ 2014-08-08 13:47 Eason Liu 阅读(417) 评论(0) 推荐(0)

[Jobdu] 题目1527:首尾相连数组的最大子数组和
摘要:题目描述:给定一个由N个整数元素组成的数组arr,数组中有正数也有负数,这个数组不是一般的数组,其首尾是相连的。数组中一个或多个连续元素可以组成一个子数组,其中存在这样的子数组arr[i],…arr[n-1],arr[0],…,arr[j],现在请你这个ACM_Lover用一个最高效的方法帮忙找出所... 阅读全文

posted @ 2014-08-08 11:33 Eason Liu 阅读(651) 评论(0) 推荐(0)

[Jobdu] 题目1497:面积最大的全1子矩阵
摘要:题目描述:在一个M * N的矩阵中,所有的元素只有0和1,从这个矩阵中找出一个面积最大的全1子矩阵,所谓最大是指元素1的个数最多。输入:输入可能包含多个测试样例。对于每个测试案例,输入的第一行是两个整数m、n(1 2 #include 3 #include 4 using namespace s... 阅读全文

posted @ 2014-08-04 17:14 Eason Liu 阅读(4616) 评论(0) 推荐(0)

[Leetcode] Longest Consecutive Sequence
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文

posted @ 2014-04-29 17:13 Eason Liu 阅读(187) 评论(0) 推荐(0)

[Leetcode] Valid Number
摘要:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文

posted @ 2014-04-29 16:27 Eason Liu 阅读(1012) 评论(0) 推荐(0)

[Leetcode] Scramble String
摘要:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文

posted @ 2014-04-28 13:20 Eason Liu 阅读(4186) 评论(1) 推荐(1)

[Leetcode] ZigZag Conversion
摘要:The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文

posted @ 2014-04-27 19:02 Eason Liu 阅读(175) 评论(0) 推荐(0)

[Leetcode] Wildcard Matching
摘要:Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the e... 阅读全文

posted @ 2014-04-27 16:19 Eason Liu 阅读(203) 评论(1) 推荐(0)

[Leetcode] 4Sum
摘要:Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文

posted @ 2014-04-27 15:13 Eason Liu 阅读(174) 评论(0) 推荐(0)

[Leetcode] Word Break II
摘要:Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possibl... 阅读全文

posted @ 2014-04-22 17:16 Eason Liu 阅读(3118) 评论(0) 推荐(0)

[Leetcode] Best Time to Buy and Sell Stock III
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文

posted @ 2014-04-22 16:34 Eason Liu 阅读(208) 评论(0) 推荐(0)

[Leetcode] Permutation Sequence
摘要: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-04-22 15:41 Eason Liu 阅读(158) 评论(0) 推荐(0)

[Leetcode] Surrounded Regions
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region... 阅读全文

posted @ 2014-04-22 15:28 Eason Liu 阅读(293) 评论(0) 推荐(0)

[Jobdu] 题目1522:包含min函数的栈
摘要:题目描述:定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。输入:输入可能包含多个测试样例,输入以EOF结束。对于每个测试案例,输入的第一行为一个整数n(1 2 #include 3 #include 4 using namespace std; 5 6 int n, a... 阅读全文

posted @ 2014-04-18 15:37 Eason Liu 阅读(212) 评论(0) 推荐(0)

[Jobdu] 题目1348:数组中的逆序对
摘要:题目描述:在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。输入:每个测试案例包括两行:第一行包含一个整数n,表示数组中的元素个数。其中1 v[right]时,cnt += 所有左边的left以后的元素的个数,而不是cnt ... 阅读全文

posted @ 2014-04-18 15:19 Eason Liu 阅读(358) 评论(0) 推荐(0)

[Leetcode] N-Queens II
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.跟上一题一样,改下结果的显示方式。 1 class S... 阅读全文

posted @ 2014-04-18 00:32 Eason Liu 阅读(242) 评论(0) 推荐(0)

[Leetcode] N-Queens
摘要:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文

posted @ 2014-04-17 18:56 Eason Liu 阅读(423) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 12 13 14 下一页