![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法解题报告
文章平均质量分 66
谢浩哲
Research Fellow at MMLab@NTU. Prev. Senior Research Scientist at Tencent AI Lab.
展开
-
Font Size
题目的来源是微软公司2016年的春季校招笔试。我又被人抱了大腿。(啥?为什么这是第一题?因为我水呀。XD)试题概述Steven loves reading book on his phone. The book he reads now consists of N paragraphs and the i-th paragraph contains ai characters.Steven want原创 2016-04-06 21:39:18 · 421 阅读 · 0 评论 -
HDOJ1003.Max Sum
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1003题目概述Given a sequence a[1],a[2],a[3]……a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in原创 2015-09-14 15:17:44 · 2426 阅读 · 0 评论 -
LeetCodeOJ.Jump Game II
试题请参见: https://leetcode.com/problems/jump-game-ii/题目概述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 max原创 2015-09-27 19:40:46 · 2898 阅读 · 0 评论 -
POJ1562.Oil Deposits
试题请参见: http://poj.org/problem?id=1562题目概述The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a原创 2015-08-06 17:42:47 · 2341 阅读 · 0 评论 -
LeetCodeOJ.Number of Digit One
试题请参见: https://leetcode.com/problems/number-of-digit-one/题目概述Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n =原创 2015-08-07 11:22:07 · 1828 阅读 · 0 评论 -
POJ2531.Network Saboteur
试题请参见: http://poj.org/problem?id=2531题目概述A university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network int原创 2015-08-06 16:31:32 · 1738 阅读 · 0 评论 -
Vijos1016.北京2008的挂钟
试题请参见: https://vijos.org/p/1016题目概述在2008北京奥运会雄伟的主会场的墙上, 挂着如上图所示的3*3的九个挂钟(一开始指针即时针指向的位置请根据输入数据调整). 然而此次奥运会给与了大家一个机会, 去用最少的移动操作改变上面的挂钟的时间全部为12点正(我们只考虑时针). 然而每一次操作并不是任意的, 我们必须按照下面给出的列表对于挂钟进行改变. 每一次操作我们给而原创 2015-08-04 17:37:40 · 2508 阅读 · 0 评论 -
POJ1579.Function Run Fun
试题请参见: http://poj.org/problem?id=1579题目概述We all love recursion! Don’t we? Consider a three-parameter recursive function w(a, b, c): if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns: 1 if a > 2原创 2015-08-02 19:46:38 · 1792 阅读 · 0 评论 -
Vijos1128.选数
试题请参见: https://vijos.org/p/1128题目概述已知 n 个整数 x1,x2,…,xn, 以及一个整数 k(k<n). 从 n 个整数中任选 k 个整数相加, 可分别得到一系列的和. 例如当 n=4, k=3, 4 个整数分别为 3, 7, 12, 19 时, 可得全部的组合与它们的和为:3+7+12=22 3+7+19=29 7+12+19=38 3+12+19=34原创 2015-08-01 15:06:56 · 4474 阅读 · 0 评论 -
POJ1664.放苹果
试题请参见: http://poj.org/problem?id=1664题目概述把M个同样的苹果放在N个同样的盘子里, 允许有的盘子空着不放, 问共有多少种不同的分法?(用K表示)5, 1, 1和1, 5, 1 是同一种分法.解题思路首先讨论N, 若N > M, 一定有空盘子, 所以F(M, N) = F(M, M). 否则, 分为两种情况:将M个苹果放入N - 1个盘子中, 即F(M, N原创 2015-08-02 20:27:50 · 2787 阅读 · 0 评论 -
POJ3278.Catch That Cow
试题请参见: http://poj.org/problem?id=3278题目概述Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line a原创 2015-08-08 16:18:07 · 1669 阅读 · 0 评论 -
HDOJ1004.Let the Balloon Rise
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1004题目概述Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most原创 2015-09-15 10:22:46 · 1888 阅读 · 0 评论 -
HDOJ1016.Prime Ring Problem
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1016题目概述A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adj原创 2015-10-05 16:56:31 · 1639 阅读 · 0 评论 -
LeetCode.Word Break
试题请参见: https://leetcode.com/problems/word-break/题目概述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For原创 2015-10-06 16:26:36 · 1861 阅读 · 0 评论 -
蛇形矩阵
本题的来源是2016年的腾讯春季校招笔试题。我只是被人抱了大腿。(o´・ェ・`o)试题描述蛇形矩阵:作为一种常用的数学数列,是由1开始的自然数依次排列成的N*N的正方形矩阵,数字依次由外向内递增,如下面实例: n = 3的蛇形矩阵 1 2 3 8 9 4 7 6 5n = 6的蛇形矩阵 1 2 3 4 5 6 20 21 22 23 24 7 19 32 33 34 25 8原创 2016-04-03 20:58:17 · 666 阅读 · 0 评论 -
LeetCode. Container With Most Water
试题概述Given n non-negative integers a1a_1, a2a_2, …, ana_n, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, aia_i) and (i,原创 2016-04-02 15:49:26 · 295 阅读 · 0 评论 -
LeetCodeOJ.ZigZag Conversion
试题请参见: https://leetcode.com/problems/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 fix原创 2016-03-18 10:54:44 · 336 阅读 · 0 评论 -
POJ2054.Color a Tree
试题请参见: http://poj.org/problem?id=2054 Also available on: http://acm.hdu.edu.cn/showproblem.php?pid=1055题目概述Bob is very interested in the data structure of a tree. A tree is a directed graph in which a原创 2015-10-14 12:23:14 · 737 阅读 · 0 评论 -
HDOJ1015.Safecracker
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1015题目概述=== Op tech briefing, 2002/11/02 06:42 CST === “The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes原创 2015-09-22 19:44:26 · 2422 阅读 · 0 评论 -
LeetCodeOJ.Longest Palindromic Substring
试题请参见: https://leetcode.com/problems/longest-palindromic-substring/题目概述Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exis原创 2015-10-09 09:42:17 · 901 阅读 · 0 评论 -
LeetCodeOJ.Longest Substring Without Repeating Characters
试题请参见: https://leetcode.com/problems/longest-substring-without-repeating-characters/题目概述Given a string, find the length of the longest substring without repeating characters. For example, the longest s原创 2015-10-08 14:03:39 · 651 阅读 · 0 评论 -
HDOJ1009.FatMouse' Trade
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1009题目概述FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehou原创 2015-09-19 11:42:23 · 1654 阅读 · 0 评论 -
HDOJ1010.Tempter of the Bone
试题请参见: http://acm.hdu.edu.cn/showproblem.php?pid=1010题目概述The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie c原创 2015-09-18 19:58:40 · 1581 阅读 · 0 评论 -
POJ2677.Tour
试题请参见: http://poj.org/problem?id=2677题目概述John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts visiting beautiful places. To save money, John must determine the s原创 2015-10-07 20:50:23 · 2120 阅读 · 0 评论 -
LeetCodeOJ. Linked List Cycle
试题请参见: https://oj.leetcode.com/problems/linked-list-cycle/题目概述Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?解题思路数据结构典型例题: 使用快慢指针. 快指针遍历原创 2015-02-21 12:26:46 · 2171 阅读 · 0 评论 -
LeetCodeOJ. Valid Parentheses
试题请参见: https://oj.leetcode.com/problems/valid-parentheses/题目概述Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must clo原创 2015-02-20 15:03:50 · 2754 阅读 · 0 评论 -
Vijos1034. 家族
试题请参见: https://vijos.org/p/1028题目概述风之子刚走进他的考场, 就……花花: 当当当当~~偶是魅力女皇——花花!!^^(华丽出场, 礼炮, 鲜花)风之子: 我呕……(杀死人的眼神)快说题目!否则……-_-###花花: ……咦~~好冷~~我们现在要解决的是魔族的密码问题(自我陶醉: 搞不好魔族里面还会有人用密码给我和菜虫写情书咧, 哦活活, 当然是给原创 2014-09-29 22:37:05 · 1822 阅读 · 0 评论 -
LeetCodeOJ. Maximum Depth of Binary Tree
试题请参见: https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/原创 2014-10-23 17:19:01 · 1809 阅读 · 0 评论 -
LeetCodeOJ. Single Number
试题请参见: https://oj.leetcode.com/problems/single-number/原创 2014-10-23 16:52:24 · 1817 阅读 · 0 评论 -
Vijos1066. 弱弱的战壕
试题请参见: https://vijos.org/p/1066题目概述输入输出解题思路遇到的问题源代码#include原创 2014-10-07 10:15:33 · 2332 阅读 · 0 评论 -
LeetCodeOJ. String to Integer (atoi)
试题请参见: https://oj.leetcode.com/problems/string-to-integer-atoi/题目概述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge,原创 2014-10-23 19:32:57 · 1817 阅读 · 0 评论 -
Vijos1025. 小飞侠的游园方案
试题请参见: https://vijos.org/p/1130题目概述我们要求找出具有下列性质数的个数(包含输入的自然数n):先输入一个自然数n(n≤1000),然后对此自然数按照如下方法进行处理1. 不作任何处理;2. 在它的左边加上一个自然数,但该自然数不能超过原数的一半;3. 加上数后,继续按此规则进行处理,直到不能再立生自然数为止.输入一个自然数n.原创 2014-09-27 09:15:41 · 2158 阅读 · 0 评论 -
Vijos1028. 魔族密码
试题请参见: https://vijos.org/p/1028题目概述经过抽签选择, 小智将军第一个进入考场. 菜虫: (身上散射出华贵(?)的光芒)欢迎你, 第一位挑战者!!小智: ……(走到菜虫身后, 关灯)女王陛下, 虽然我们国家现在很富裕, 但也请您不要浪费电来用这么大功率的灯泡. 菜虫(汗): 啊啊~~爱卿所言甚是~~那么, 你的题目是……我们的情报组织探听到敌人的重原创 2014-09-28 10:15:04 · 2000 阅读 · 0 评论 -
Vijos1130. 数的计数
试题请参见: http://pat.zju.edu.cn/contests/pat-a-practise/1016题目概述假设有N个客户在K个窗口等待服务。 每个窗口可以容纳一个人, 因此其他客户需要进行等待. 当某个客户服务完成后, 下一个客户可以进入该窗口并被服务. 我们假设没有窗口会被占用1小时以上.现在我们给出每个客户的到达时间T和服务该客户所需要的时间P, 请计算所有原创 2014-09-26 15:56:35 · 1855 阅读 · 0 评论 -
PAT1017. Queueing at Bank
试题请参见: http://pat.zju.edu.cn/contests/pat-a-practise/1017题目概述系统会记录每个客户的通话情况, 会告诉你每个时间段(00:00~01:00, 01:00~02:00, ...)的通话费用. 要求计算出每个客户的月账单情况.输入每个输入包含测试用例, 每个测试用例包含两部分: 每个时间段的通话费用(原创 2014-09-25 11:21:18 · 2112 阅读 · 1 评论 -
PAT1016. Phone Bills
试题请参见: http://pat.zju.edu.cn/contests/pat-a-practise/1016题目概述系统会记录每个客户的通话情况, 会告诉你每个时间段(00:00~01:00, 01:00~02:00, ...)的通话费用. 要求计算出每个客户的月账单情况.输入每个输入包含测试用例, 每个测试用例包含两部分: 每个时间段的通话费用和每个客户的通话情况.通话原创 2014-09-24 10:47:46 · 2060 阅读 · 0 评论 -
LeetCodeOJ. Count and Say
试题请参见: https://oj.leetcode.com/problems/string-to-integer-atoi/原创 2014-10-24 15:14:25 · 1614 阅读 · 0 评论 -
Vijos1090. 连续数之和
试题请参见: https://vijos.org/p/1090题目概述有n个正整数排成一行。你的目的是要从中取出一个或连续的若干个数,使它们的和能够被k整除。例如,有6个正整数,它们依次为1、2、6、3、7、4。若k=3,则你可以取出1、2、6,或者2、6、3、7,也可以仅仅取出一个6或者3使你所取的数之和能被3整除。当然,满足要求的取法不止以上这4种。事实上,一共有7种取法满原创 2014-10-10 09:12:53 · 2505 阅读 · 0 评论 -
LeetCodeOJ. Symmetric Tree
试题请参见: https://oj.leetcode.com/problems/symmetric-tree/题目概述原创 2014-10-29 13:40:17 · 1800 阅读 · 0 评论 -
LeetCodeOJ. Excel Sheet Column Title
试题请参见: https://oj.leetcode.com/problems/excel-sheet-column-title/题目概述Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26原创 2015-02-21 12:09:41 · 2306 阅读 · 0 评论