
针对lcy编程
黑夜中坚持
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
无重复字符子集问题
Description Mike is a lawyer with the gift of photographic memory. He is so good with it that he can tell you all the numbers on a sheet of paper by having a look at it without any mistake. Mike is al...原创 2019-12-05 08:00:58 · 206 阅读 · 0 评论 -
是否能通过考试
Description 小张想要通过明天的考试。他知道考题的分值分布,也知道考试中要拿到每一个题目需要耗费的时间。假设考试时长为h,共n个题目,需要拿到p分才能通过考试。现在已知每个考题的得分与耗时,请你判断小张能否通过合理安排时间,而通过考试,并给出通过考试的最短时间。 Input 输入第一行为测试用例个数.每一个用例有若干行,第一行为任务数量n、考试时常h、通过分数p,下面的n行是每一个题目的...原创 2019-12-05 07:59:28 · 255 阅读 · 0 评论 -
如何花最少的钱购买蔬菜
Description Rahul wanted to purchase vegetables mainly brinjal, carrot and tomato. There are N different vegetable sellers in a line. Each vegetable seller sells all three vegetable items, but at diff...原创 2019-12-04 23:39:33 · 224 阅读 · 0 评论 -
按照要求保留数组元素使得和最大
Description Given an array of N numbers, we need to maximize the sum of selected numbers. At each step, you need to select a number Ai, delete one occurrence of Ai-1 (if exists) and Ai each from the a...原创 2019-12-04 23:38:27 · 179 阅读 · 0 评论 -
数组查询
数组查询 Description Given an array, the task is to complete the function which finds the maximum sum subarray, where you may remove at most one element to get the maximum sum. Input 第一行为测试用例个数T;后面每两行表示一个...原创 2019-12-04 23:37:13 · 283 阅读 · 0 评论 -
订单问题
Description Rahul and Ankit are the only two waiters in Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when handled by different waiters, if Rahul takes the i...原创 2019-12-04 21:44:52 · 529 阅读 · 0 评论 -
最小化初始点(倒推的动态规划)
最小化初始点 Description Given a grid with each cell consisting of positive, negative or no points i.e, zero points. We can move across a cell only if we have positive points ( > 0 ). Whenever we pass th...原创 2019-12-04 21:23:13 · 344 阅读 · 0 评论 -
管道网络
Description Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps are to be installed in a manner such that every house with one outgoing pi...原创 2019-12-04 20:14:25 · 427 阅读 · 0 评论 -
格子里的整数
Description Given a square grid of size n, each cell of which contains integer cost which represents a cost to traverse through that cell, we need to find a path from top left cell to bottom right cel...原创 2019-12-04 19:10:51 · 299 阅读 · 0 评论 -
路上的球
Description There are two parallel roads, each containing N and M buckets, respectively. Each bucket may contain some balls. The buckets on both roads are kept in such a way that they are sorted accor...原创 2019-12-04 19:09:23 · 189 阅读 · 0 评论 -
字符串4(动态规划实现).最长公共子序列
Description 给定两个字符串,返回两个字符串的最长公共子序列(不是最长公共子字符串),可能是多个。 Input 输入第一行为用例个数, 每个测试用例输入为两行,一行一个字符串 Output 如果没有公共子序列,不输出,如果有多个则分为多行,按字典序排序。 Sample Input 1 1 1A2BD3G4H56JK 23EFG4I5J6K7 Sample Output 1 23G456K...原创 2019-12-04 10:35:37 · 147 阅读 · 0 评论 -
字符串3.和最大的连续降序字符
Description Archana is very fond of strings. She likes to solve many questions related to strings. She comes across a problem which she is unable to solve. Help her to solve. The problem is as follows...原创 2019-12-04 09:15:15 · 342 阅读 · 0 评论 -
字符串2.字符串匹配问题
Description Given a text txt[0…n-1] and a pattern pat[0…m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may assume that n > m. Input 输入第一行是用...原创 2019-12-03 12:04:07 · 189 阅读 · 1 评论 -
字符串1.对称子字符串
Description Given a string ‘str’ of digits, find length of the longest substring of ‘str’, such that the length of the substring is 2k digits and sum of left k digits is equal to the sum of right k di...原创 2019-12-03 11:47:25 · 309 阅读 · 0 评论 -
排序7.按照数值个数排序
Description 对给定数组中的元素按照元素出现的次数排序,出现次数多的排在前面,如果出现次数相同,则按照数值大小排序。例如,给定数组为{2, 3, 2, 4, 5, 12, 2, 3, 3, 3, 12},则排序后结果为{3, 3, 3, 3, 2, 2, 2, 12, 12, 4, 5}。 Input 输入的第一行为用例个数;后面每一个用例使用两行表示,第一行为数组长度,第二行为数组内容...原创 2019-12-03 11:21:20 · 445 阅读 · 0 评论 -
排序6.shell排序
Description 实现Shell排序,对给定的无序数组,按照给定的间隔变化(间隔大小即同组数字index的差),打印排序结果,注意不一定是最终排序结果! Input 输入第一行表示测试用例个数,后面为测试用例,每一个用例有两行,第一行为给定数组,第二行为指定间隔,每一个间隔用空格隔开。 Output 输出的每一行为一个用例对应的指定排序结果。 Sample Input 1 1 49 38 6...原创 2019-12-03 11:10:28 · 408 阅读 · 0 评论 -
排序5.非递归合并排序
Description 合并(归并)排序的核心思想是:每次从中间位置将数组分组再分别排序。请实现其非递归方案。 Input 输入的每一行表示一个元素为正整数的数组,所有值用空格隔开,第一个值为数值长度,其余为数组元素值。 Output 输出的每一行为排序结果,用空格隔开,末尾不要空格。 Sample Input 1 13 24 3 56 34 3 78 12 29 49 84 51 9 100 S...原创 2019-12-03 10:14:25 · 177 阅读 · 0 评论 -
排序4.非递归快排
Description 快速排序的核心思想是使用元素的值对数组进行划分。实现其非递归方案。 Input 输入的每一行表示一个元素为正整数的数组,所有值用空格隔开,第一个值为数值长度,其余为数组元素值。 Output 输出的每一行为排序结果,用空格隔开,末尾不要空格。 Sample Input 1 13 24 3 56 34 3 78 12 29 49 84 51 9 100 Sample Outp...原创 2019-12-03 09:14:00 · 116 阅读 · 0 评论 -
排序3.计数排序
Description 实现计数排序,通过多次遍历数组,统计比每一个元素小的其它元素个数,根据该统计量对数据进行排序。 Input 输入的每一行表示一个元素为正整数的数组,所有值用空格隔开,第一个值为数值长度,其余为数组元素值。 Output 输出的每一行为排序结果,用空格隔开,末尾不要空格。 Sample Input 1 13 24 3 56 34 3 78 12 29 49 84 51 9 1...原创 2019-12-02 21:12:13 · 220 阅读 · 0 评论 -
排序2.冒泡排序
Description 实现冒泡排序。 Input 输入的每一行表示一个元素为正整数的数组,所有值用空格隔开,第一个值为数值长度,其余为数组元素值。 Output 输出的每一行为排序结果,用空格隔开,末尾不要空格。 Sample Input 1 13 24 3 56 34 3 78 12 29 49 84 51 9 100 Sample Output 1 3 3 9 12 24 29 34 49 ...原创 2019-12-02 19:44:44 · 238 阅读 · 0 评论 -
排序1.插入排序
Description 实现插入排序。 Input 输入第一行为用例个数, 每个测试用例输入的每一行代表一个数组,其中的值用空格隔开,第一个值表示数组的长度。 Output 输出排序的数组,用空格隔开,末尾不要空格。 Sample Input 1 1 13 24 3 56 34 3 78 12 29 49 84 51 9 100 Sample Output 1 3 3 9 12 24 29 34 ...原创 2019-12-02 19:25:19 · 309 阅读 · 0 评论 -
管道网络
Description Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps are to be installed in a manner such that every house with one outgoing pi...原创 2019-11-28 15:26:51 · 336 阅读 · 0 评论 -
时间分隔(车站到站)
Description Given arrival and departure times of all trains that reach a railway station. Your task is to find the minimum number of platforms required for the railway station so that no train waits. ...原创 2019-11-28 15:25:01 · 366 阅读 · 0 评论 -
时间与收益
Description Given a set of n jobs where each job i has a deadline and profit associated to it. Each job takes 1 unit of time to complete and only one job can be scheduled at a time. We earn the profit...原创 2019-11-28 14:51:51 · 329 阅读 · 0 评论 -
硬币最小数量
Description Given the list of coins of distinct denominations and total amount of money. Output the minimum number of coins required to make up that amount. Output -1 if that money cannot be made up u...原创 2019-11-28 14:46:07 · 299 阅读 · 0 评论 -
17.距离问题
Description In a given cartesian plane, there are N points. We need to find the Number of Pairs of points(A,B) such that Point A and Point B do not coincide. Manhattan Distance and the Euclidean Dista...原创 2019-11-27 21:12:50 · 354 阅读 · 0 评论 -
16.书本分发
Description You are given N number of books. Every ith book has Pi number of pages. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permuta...原创 2019-11-27 20:29:52 · 676 阅读 · 0 评论 -
15.字符串匹配问题
Description Given a text txt[0…n-1] and a pattern pat[0…m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may assume that n > m. Input 输入第一行是用...原创 2019-11-27 20:08:48 · 250 阅读 · 0 评论 -
14.按另外一个数组排序
Description Given two array A1[] and A2[], sort A1 in such a way that the relative order among the elements will be same as those in A2. For the elements not present in A2. Append them at last in sort...原创 2019-11-27 19:57:35 · 212 阅读 · 0 评论 -
无重复字符子集问题
Description Mike is a lawyer with the gift of photographic memory. He is so good with it that he can tell you all the numbers on a sheet of paper by having a look at it without any mistake. Mike is al...原创 2019-11-26 15:17:09 · 515 阅读 · 0 评论 -
12.数组查询
Description Given an array, the task is to complete the function which finds the maximum sum subarray, where you may remove at most one element to get the maximum sum. Input 第一行为测试用例个数T;后面每两行表示一个用例,第一...原创 2019-11-26 11:58:43 · 228 阅读 · 0 评论 -
10.点的凸包
点的凸包 Description Convex Hull of a set of points, in 2D plane, is a convex polygon with minimum area such that each point lies either on the boundary of polygon or inside it. Now given a set of points ...转载 2019-11-26 11:55:22 · 361 阅读 · 0 评论 -
9.有9个因数的数
有9个因数的数 Description Find the count of numbers less than N having exactly 9 divisors 1<=T<=1000,1<=N<=10^12 Input First Line of Input contains the number of testcases. Only Line of each tes...原创 2019-11-26 10:46:38 · 539 阅读 · 0 评论 -
7.整除查询
Description Given an array of positive integers and many queries for divisibility. In every query Q[i], we are given an integer K , we need to count all elements in the array which are perfectly divis...原创 2019-11-25 21:49:51 · 215 阅读 · 0 评论 -
8.数学公式
Description Implement pow(A, B) % C.In other words, given A, B and C, find (A^B)%C Input The first line of input consists number of the test cases. The following T lines consist of 3 numbers each sepa...原创 2019-11-25 21:48:44 · 306 阅读 · 0 评论 -
6.漆狗屋
Description Dilpreet wants to paint his dog- Buzo’s home that has n boards with different lengths[A1, A2,…, An]. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of...原创 2019-11-25 21:29:56 · 365 阅读 · 0 评论 -
5.订单问题
Description Rahul and Ankit are the only two waiters in Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when handled by different waiters, if Rahul takes the i...原创 2019-11-25 19:57:54 · 295 阅读 · 0 评论 -
4.序号乘方
Description There are Infinite People Standing in a row, indexed from 1.A person having index ‘i’ has strength of (i*i).You have Strength ‘P’. You need to tell what is the maximum number of People You...原创 2019-11-25 16:47:33 · 474 阅读 · 0 评论 -
3.对称子字符串
Description Given a string ‘str’ of digits, find length of the longest substring of ‘str’, such that the length of the substring is 2k digits and sum of left k digits is equal to the sum of right k di...原创 2019-11-25 16:40:59 · 252 阅读 · 0 评论 -
2. 无限递归字符串查询
Description Consider a string A = “12345”. An infinite string s is built by performing infinite steps on A recursively. In i-th step, A is concatenated with ‘’itimesfollowedbyreverseofA.A=A∣’ i times ...原创 2019-11-25 16:34:56 · 195 阅读 · 0 评论