模拟题
文章平均质量分 75
模拟
master-dragon
weixin:dwl_1270530306
展开
-
04-树9. Path in a Heap (25) -- 小堆树-利用其性质
题目地址:http://www.patest.cn/contests/mooc-ds/04-%E6%A0%919/*04-树9. Path in a Heap (25)http://www.patest.cn/contests/mooc-ds/04-%E6%A0%919节点编号为i的 两个孩子编号 2*i , 2*i+1一个节点编号为i的父节点编号 i/2(i为奇数和偶数都一样)*/#i原创 2015-08-22 16:12:12 · 586 阅读 · 0 评论 -
1105. Spiral Matrix (25) / 1050. 螺旋矩阵(25) 考察代码优化,而非算法
1105. Spiral Matrix (25)时间限制150 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThis time your job is to fill a sequence of原创 2016-01-20 14:54:16 · 812 阅读 · 0 评论 -
55. Jump Game (leetcode)
题目地址 https://leetcode.com/problems/jump-game/题目描述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 maximum原创 2016-10-04 18:57:51 · 284 阅读 · 0 评论 -
1017. Queueing at Bank (25)
题目地址https://www.patest.cn/contests/pat-a-practise/1017题目描述Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. Al原创 2016-11-19 10:11:40 · 409 阅读 · 0 评论 -
1016. Phone Bills (25)
题目地址https://www.patest.cn/contests/pat-a-practise/1016题目描述A long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, d原创 2016-11-19 12:14:02 · 398 阅读 · 0 评论 -
5-3 Pop Sequence (25分) / PAT 1051. Pop Sequence (25)
5-3 Pop Sequence (25分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of n原创 2015-10-26 19:50:40 · 575 阅读 · 0 评论 -
leetcode 76 Minimum Window Substring/ 209 Minimum Size Subarray Sum
主要是如何模拟209 Minimum Size Subarray Sum可以直接利用队列模拟76. Minimum Window Substring转载参考 makuiyu LeetCode — 76. Minimum Window Substring 地址http://blog.csdn.net/makuiyu/article/details/44570193ac代码class Soluti转载 2016-12-13 21:47:10 · 378 阅读 · 0 评论 -
折纸问题(牛客网) 。。。
问题和讨论 见牛客网 https://www.nowcoder.com/questionTerminal/430180b66a7547e1963b69b1d0efbd3c问题描述请把纸条竖着放在桌⼦上,然后从纸条的下边向上⽅对折,压出折痕后再展 开。此时有1条折痕,突起的⽅向指向纸条的背⾯,这条折痕叫做“下”折痕 ;突起的⽅向指向纸条正⾯的折痕叫做“上”折痕。如果每次都从下边向上⽅ 对折,对折N次转载 2016-12-14 14:31:43 · 2552 阅读 · 0 评论 -
1057. Stack (30) - 剑指offer 数据流中的中位数
题目地址:http://www.patest.cn/contests/pat-a-practise/1057/*http://www.patest.cn/contests/pat-a-practise/10571057. Stack (30)// 可以插入相同的元素multiset<int> qmax; // 从小到大排列// 从大到小排列 cmp return a>b 表示大的在前面mu原创 2015-09-02 20:48:20 · 847 阅读 · 0 评论 -
全排列,字典顺序问题 ( permutations/leetcode)
46. Permutations题目地址 https://leetcode.com/problems/permutations/注意是distinct numbers,所以相对简单, 当然写出好的代码也是困难的,下面是ac代码(效率可能不高)方法1:采用dfs遍历class Solution {private: vector<vector<int>> ans; vector<in原创 2016-09-29 21:01:34 · 1464 阅读 · 0 评论 -
1051. Pop Sequence (25) -- 栈模拟 经典
http://www.patest.cn/contests/mooc-ds/02-%E7%BA%BF%E6%80%A7%E7%BB%93%E6%9E%844Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supp原创 2015-08-21 10:39:06 · 509 阅读 · 0 评论 -
求前缀表达式的值(pat), 后缀表达式求解(leetcode)
[题目地址](http://www.patest.cn/contests/mooc-ds/02-%E7%BA%BF%E6%80%A7%E7%BB%93%E6%9E%843) 算术表达式有前缀表示法、中缀表示法和后缀表示法等形式。前缀表达式指二元运算符位于两个运算数之前,例如2+3*(7-4)+8/4的前缀表达式是:+ + 2 * 3 - 7 4 / 8 4。请设计程序计算前缀表达式的结果值原创 2015-08-20 15:23:12 · 1876 阅读 · 0 评论 -
System Overload
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1088Recently you must have experienced that when too many people use the BBS simultaneously, the net becomes very, very slow. To put an end原创 2015-07-03 22:02:29 · 677 阅读 · 0 评论 -
1067. Sort with Swap(0,*) (25)
题目地址:http://www.patest.cn/contests/pat-a-practise/1067http://www.patest.cn/contests/mooc-ds/08-%E6%8E%92%E5%BA%8F5/*利用了 c++STL中的 map 和 set */#include <cstdio> #include <sstream> #include <cstrin原创 2015-08-21 17:37:58 · 503 阅读 · 0 评论 -
05-图2. Saving James Bond - Easy Version (25)
题目地址:http://www.patest.cn/contests/mooc-ds/05-%E5%9B%BE2题目不难, 就用队列模拟一下就行 中间是 15个单位长 直径 圆, 所以算距离的时候要注意#include <cstdio> #include <sstream> #include <cstring> #include <iostream>#include <string>原创 2015-08-22 16:07:02 · 419 阅读 · 0 评论 -
00-自测5. Shuffling Machine (20)
http://www.patest.cn/contests/mooc-ds/00-%E8%87%AA%E6%B5%8B5模拟,就是排序, 定义好结构体#include <cstdio> #include <sstream> #include <cstring> #include <iostream>#include <string>#include <vector>#include原创 2015-08-20 15:31:52 · 483 阅读 · 0 评论 -
1008. Elevator (20)
1008. Elevator (20)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specifie原创 2015-10-15 11:13:48 · 298 阅读 · 0 评论 -
1095. Cars on Campus (30) -- 模拟,map , vector , 逻辑处理 -- 需敲20遍
1095. Cars on Campus (30)时间限制220 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueZhejiang University has 6 campuses and a lo原创 2015-12-03 13:31:02 · 695 阅读 · 0 评论 -
5-48 银行排队问题之单窗口“夹塞”版 (30分)
5-48 银行排队问题之单窗口“夹塞”版 (30分)排队“夹塞”是引起大家强烈不满的行为,但是这种现象时常存在。在银行的单窗口排队问题中,假设银行只有1个窗口提供服务,所有顾客按到达时间排成一条长龙。当窗口空闲时,下一位顾客即去该窗口处理事务。此时如果已知第ii位顾客与排在后面的第jj位顾客是好朋友,并且愿意替朋友办理事务的话,那么第ii位顾客的事务处理时间就是自己的事务加朋友原创 2016-04-30 08:20:54 · 3595 阅读 · 0 评论 -
多数组中位数,k大数 -- 二分思路
多数组k大数给定两个有序数组arr1和arr2,在给定一个整数k,返回两个数组的所有数中第K小的数。 例如: arr1 = {1,2,3,4,5}; arr2 = {3,4,5}; K = 1; 因为1为所有数中最小的,所以返回1;arr1 = {1,2,3}; arr2 = {3,4,5,6}; K = 4; 因为3为所有数中第4小的数,所以返回3;要求:如果arr1的长度为N,a原创 2016-08-15 19:02:37 · 1496 阅读 · 0 评论 -
合理的出栈序列, 卡特兰数, 栈:先进后出
(合理数目 是 卡特兰数 C2n n / (n+1))例如 abc 有5种合理的顺序, 打印如下cbabcabacacbabcabcd 有 14中合理的顺序,打印如下dcbacdbacbdacbadbdcabcdabcadbadcbacdadcbacdbacbdabdcabcd当时笔试没写好,时间有点紧,先把代码思路整理如下(?,应该是对的,还要仔细验证下原创 2017-10-14 18:28:53 · 546 阅读 · 0 评论