算法
comeonsolo
这个作者很懒,什么都没留下…
展开
-
LeetCode: -Dynamic Programming-Strange Printer[664]
题目一个打印机,每一轮能打印一个同一个字符的序列,能在下一轮在任何位置开始任何位置结束打印一个其他的字符。后打印的将覆盖先打印的。 给定一个字符串,求最小的打印轮次。示例:Input: "aaabbb" Output: 2 Explanation: 先打印 "aaa" 再打印 "bbb".Input: "aba" Output: 2 Explanation: 先打印 "aaa" 再从第二个位置打印原创 2017-09-04 16:43:07 · 1286 阅读 · 1 评论 -
nowcoder-顺时针打印矩阵-模拟魔方逆时针旋转
题目顺时针打印矩阵输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.矩阵为:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1原创 2017-09-15 15:55:26 · 508 阅读 · 0 评论 -
足球赛确定淘汰赛名单-map<string, int>问题
科大讯飞笔试题:题意足球赛确定淘汰赛名单 比赛规则: 1、参赛队伍为n支, n为偶数。 2、入围淘汰赛队伍为n/2支。 3、按积分排名,胜一场积3分,平一场积1分, 负一场积0分,积分相同按净胜球排名,净胜球相同按进球数排名。输入输出第一行为一个整数n,参赛队伍数 随后n行为球队名字 随后n*(n-1)/2行为赛事开展情况,格式为 name1-name2 num1:num2 输出n/2行原创 2017-09-16 19:45:06 · 630 阅读 · 0 评论 -
LeetCode: -Dynamic Programming-House Robber[198]
求非负整数数组中取一些元素的和的最大值,要求不能取相邻的元素You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each o原创 2017-09-08 15:14:18 · 235 阅读 · 0 评论 -
LeetCode: -Dynamic Programming-Best Time to Buy and Sell Stock[121]
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2017-09-08 15:40:09 · 186 阅读 · 0 评论 -
LeetCode: -Dynamic Programming-Maximum Subarray[53]-子数组最大和
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the原创 2017-09-09 11:17:24 · 206 阅读 · 0 评论 -
LeetCode: -Dynamic Programming-2 Keys Keyboard[650]-复制粘贴问题
题目:一个A,通过复制粘贴操作,实现n个A需要的最少步数。 每步可以有以下选择: 1、复制,复制已有的所有A; 2、粘贴,粘贴上次复制的内容。注意:n的范围在[1, 1000]Initially on a notepad only one character ‘A’ is present. You can perform two operations on this notepad for e原创 2017-09-09 14:16:11 · 324 阅读 · 0 评论 -
LeetCode: -Dynamic Programming-Continuous Subarray Sum[523]
题目非负整数数组中,连续子数组(子数组长度最小为2)和为k的倍数,是否存在的问题。Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to原创 2017-09-12 11:12:42 · 234 阅读 · 0 评论