
刷题
hh66__66hh
这个作者很懒,什么都没留下…
展开
-
LeetCode860.Lemonade Change
LeetCode860.Lemonade Change题目At a lemonade stand, each lemonade costs $5.Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills).Each customer ...原创 2018-09-30 20:31:25 · 185 阅读 · 0 评论 -
【PAT数据结构与算法题目集】六度空间(多源最短路径)
【PAT数据结构与算法题目集】六度空间(多源最短路径)题目六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”“六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力...原创 2018-11-05 21:08:52 · 1765 阅读 · 0 评论 -
【PAT数据结构与算法题目集】列出连通集(图的遍历)
【PAT数据结构与算法题目集】列出连通集(图的遍历)题目给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。输入格式:输入第1行给出2个整数N(0<N≤10)和E,分别是图的顶点数和边数。随后E行,每行给出一条边的两个端点。每行中的数字之间用1空格分隔。输出...原创 2018-11-05 11:27:17 · 706 阅读 · 0 评论 -
【PAT数据结构与算法题目集】公路村村通(最小生成树)
【PAT数据结构与算法题目集】公路村村通(最小生成树)题目现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。输入格式:输入数据包括城镇数目正整数N(≤1000)和候选道路数目M(≤3N);随后的M行对应M条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路改建的预算成本。为简单起见,城镇从1到N编号...原创 2018-11-03 19:17:39 · 666 阅读 · 0 评论 -
【LeetCode】1000. Minimum Cost to Merge Stones(DP)
【LeetCode】1000. Minimum Cost to Merge Stones(DP)题目There are N piles of stones arranged in a row. The i-th pile has stones[i] stones.A move consists of merging exactly K consecutive piles into one ...原创 2019-03-03 19:01:42 · 793 阅读 · 0 评论 -
【LeetCode】1004. Max Consecutive Ones III(滑动窗口)
【LeetCode】1004. Max Consecutive Ones III(滑动窗口)题目Given an array A of 0s and 1s, we may change up to K values from 0 to 1.Return the length of the longest (contiguous) subarray that contains only 1s....原创 2019-03-04 12:23:21 · 404 阅读 · 0 评论 -
【hihocoder】1936.连续整数列(滑动窗口)
【hihocoder]1936.连续整数列(滑动窗口)1. 题目小Hi有N张卡片,其中第i张卡片上写着一个整数Ai。现在小Hi希望这N张卡片上的数字能组成一个长度为N连续整数列,则他至少需要改变多少张卡片上的整数?输入第一行包含一个整数N。第二行包含N个整数A1, A2, … AN.1 <= N <= 1000001 <= Ai <= 1000000输出一...原创 2019-03-10 16:37:21 · 265 阅读 · 0 评论 -
【hihocoder】1938.还原BST(层序遍历+BST)
【hihocoder】1938.还原BST(层序遍历+BST)1. 题目小Hi有一棵二叉搜索树(BST)。小Ho想知道这颗树的结构。小Hi为了考验一下小Ho,只告诉他这棵BST的层序遍历(从上到下、从左到右)序列。例如如下的BST,层序遍历序列是:5, 3, 10, 1, 4, 7 5 / \ 3 10 / \ ...原创 2019-03-11 20:04:21 · 322 阅读 · 0 评论 -
【LeetCode】1013. Pairs of Songs With Total Durations Divisible by 60(取模)
【LeetCode】1013. Pairs of Songs With Total Durations Divisible by 60(取模)题目In a list of songs, the i-th song has a duration of time[i] seconds.Return the number of pairs of songs for which their tota...原创 2019-03-17 13:42:56 · 417 阅读 · 0 评论 -
【LeetCode】1014. Capacity To Ship Packages Within D Days + 875. Koko Eating Bananas(二分搜索)
【LeetCode】1014. Capacity To Ship Packages Within D Days(二分搜索)题目A conveyor belt has packages that must be shipped from one port to another within D days.The i-thpackage on the conveyor belt has a we...原创 2019-03-17 16:01:22 · 587 阅读 · 0 评论 -
【LeetCode】1020. Number of Enclaves(图搜索)
【LeetCode】1020. Number of Enclaves(图搜索)题目Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)A move consists of walking from one land square 4-directionally to another lan...原创 2019-03-31 15:18:08 · 660 阅读 · 0 评论 -
【LeetCode】1019. Next Greater Node In Linked List
【LeetCode】1019. Next Greater Node In Linked List题目We are given a linked list with head as the first node. Let’s number the nodes in the list: node_1, node_2, node_3, … etc.Each node may have a nex...原创 2019-03-31 15:37:28 · 331 阅读 · 0 评论 -
【PAT数据结构与算法题目集】 哈利·波特的考试 (Floyd算法)
【PAT数据结构与算法题目集】 哈利·波特的考试 (Floyd算法)题目哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠、老鼠变鱼的魔咒...原创 2018-11-07 11:22:49 · 329 阅读 · 0 评论 -
【PAT数据结构与算法题目集】 旅游规划(单源最短路径,长度+路径查找)
【PAT数据结构与算法题目集】 旅游规划(单源最短路径)题目有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的...原创 2018-11-07 13:59:38 · 2092 阅读 · 0 评论 -
【PAT数据结构与算法题目集】地下迷宫探索(深度优先搜索)
【PAT数据结构与算法题目集】地下迷宫探索(深度优先搜索)题目地道战是在抗日战争时期,在华北平原上抗日军民利用地道打击日本侵略者的作战方式。地道网是房连房、街连街、村连村的地下工事。我们在回顾前辈们艰苦卓绝的战争生活的同时,真心钦佩他们的聪明才智。在现在和平发展的年代,对多数人来说,探索地下通道或许只是一种娱乐或者益智的游戏。本实验案例以探索地下通道迷宫作为内容。假设有一个地下通道迷宫,它的...原创 2018-11-11 09:22:15 · 1167 阅读 · 2 评论 -
LeetCode #859. Buddy Strings
LeetCode #859. Buddy Strings题目描述Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B. Example 1:Input: A = "ab",...原创 2018-09-16 20:35:41 · 181 阅读 · 0 评论 -
LeetCode #665. Non-decreasing Array
665. Non-decreasing Array题目描述Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if arra...原创 2018-09-15 11:09:25 · 157 阅读 · 0 评论 -
LeetCode #26. Remove Duplicates from Sorted Array
26. Remove Duplicates from Sorted Array题目描述Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra spa...原创 2018-09-10 20:36:09 · 146 阅读 · 0 评论 -
LeetCode #20. Valid Parentheses
LeetCode #20. Valid Parentheses题目描述Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:1.Open brac...原创 2018-09-08 21:17:40 · 147 阅读 · 0 评论 -
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) A
A. Andryusha and Sockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndryusha is an orderly boy and likes to keep things ...原创 2017-04-18 18:19:49 · 457 阅读 · 0 评论 -
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) C
C. Andryusha and Colored Balloonstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAndryusha goes through a park each day. The squ...原创 2017-04-19 13:12:14 · 229 阅读 · 0 评论 -
【Offer收割】编程练习赛38 —— 漏写的数字
漏写的数字小A今年刚上幼儿园,正在学习写100以内的数字。幼儿园的老师留了一项作业,要求小A从某个100以内的数X开始一直写到另一个100以内的数Y(Y - X > 1)。 不过粗心的小A在作业中漏写了一个整数(好在小A漏写的不是X,并且至少写下了2个整数)。给定小A写下的数字串,你能求小A漏写的数字是多少吗?输入 一个只包含数字的字符串。注意小A至少写下了两个数。输出 小A漏写的数字。样例输原创 2017-12-07 19:56:53 · 543 阅读 · 0 评论 -
LeetCode #14. Longest Common Prefix
LeetCode #14. Longest Common Prefix题目描述Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1...原创 2018-09-08 20:45:59 · 185 阅读 · 0 评论 -
LeetCode#732 My Calendar My Calendar III
LeetCode#732 My Calendar My Calendar III题目Implement a MyCalendarThree class to store your events. A new event can always be added.Your class will have one method, book(int start, int end). Formally...原创 2018-10-13 08:48:08 · 301 阅读 · 0 评论 -
[Offer收割]编程练习赛79——字母去重
[Offer收割]编程练习赛79——字母去重题目时间限制:10000ms单点时限:1000ms内存限制:256MB描述给定一个字符串S,每次操作你可以将其中任意一个字符修改成其他任意字符。请你计算最少需要多少次操作,才能使得S中不存在两个相邻的相同字符。输入只包含小写字母的字符串S。1 ≤ |S| ≤ 100000输出一个整数代表答案样例输入aab样例输出1思...原创 2018-10-20 15:04:59 · 887 阅读 · 0 评论 -
【PAT数据结构与算法题目集】社交网络图中结点的“重要性”计算(单源最短路径)
【PAT数据结构与算法题目集】社交网络图中结点的“重要性”计算(单源最短路径)题目在社交网络中,个人或单位(结点)之间通过某些关系(边)联系起来。他们受到这些关系的影响,这种影响可以理解为网络中相互连接的结点之间蔓延的一种相互作用,可以增强也可以减弱。而结点根据其所处的位置不同,其在网络中体现的重要性也不尽相同。“紧密度中心性”是用来衡量一个结点到达其它结点的“快慢”的指标,即一个有较高中心...原创 2018-11-19 20:02:50 · 676 阅读 · 0 评论 -
【LeetCode】1017. Convert to Base -2(十进制转换为负整数进制)
【LeetCode】1017. Convert to Base -2(十进制转换为负整数进制)题目Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two).The returned string must have no l...原创 2019-03-31 15:59:23 · 709 阅读 · 0 评论