01 2019 档案

摘要:We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclid 阅读全文 »
posted @ 2019-01-31 22:50 Veritas_des_Liberty 阅读(438) 评论(0) 推荐(0) 编辑
摘要:For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such that: For every i < j, there is no k with i < k < 阅读全文 »
posted @ 2019-01-31 22:37 Veritas_des_Liberty 阅读(255) 评论(0) 推荐(0) 编辑
摘要:We are given S, a length n string of characters from the set {'D', 'I'}. (These letters stand for "decreasing" and "increasing".) A valid permutation  阅读全文 »
posted @ 2019-01-30 23:43 Veritas_des_Liberty 阅读(384) 评论(0) 推荐(0) 编辑
摘要:In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to s 阅读全文 »
posted @ 2019-01-30 23:04 Veritas_des_Liberty 阅读(358) 评论(0) 推荐(0) 编辑
摘要:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon 阅读全文 »
posted @ 2019-01-30 22:09 Veritas_des_Liberty 阅读(161) 评论(0) 推荐(0) 编辑
摘要:描述 写一个程序完成以下命令:new id ——新建一个指定编号为id的序列(id<10000)add id num——向编号为id的序列加入整数nummerge id1 id2——合并序列id1和id2中的数,并将id2清空unique id——去掉序列id中重复的元素out id ——从小到大输 阅读全文 »
posted @ 2019-01-29 23:35 Veritas_des_Liberty 阅读(602) 评论(0) 推荐(0) 编辑
摘要:描述 下面的程序输出结果是: 1 2 6 7 8 9 请填空: 输入无输出1 2 6 7 8 9样例输入 样例输出 Approach #1: Analysis: 看到头文件中有set,很自然地就想到了用set来做这道题。刚开始想的是用set<int> v(a, a+7)来初始化set,但是这种方法, 阅读全文 »
posted @ 2019-01-29 23:33 Veritas_des_Liberty 阅读(362) 评论(0) 推荐(0) 编辑
摘要:greater 的应用 list 有两个sort成员函数  void sort(); 将list中的元素按 “<” 规定的比较方法升序排列。  template void sort (Compare op); 将list中的元素按 op 规定的比较方法升序排列。即要比较x,y 大小时,看 op( 阅读全文 »
posted @ 2019-01-29 21:26 Veritas_des_Liberty 阅读(244) 评论(0) 推荐(0) 编辑
摘要:STL中“大”“小” 的概念: 关联容器内部的元素是从小到大排序的 有些算法要求其操作的区间是从小到大排序的,称为“有序区间算法”例:binary_search 有些算法会对区间进行从小到大排序,称为“排序算法”例: sort 还有一些其他算法会用到“大”,“小”的概念使用STL时,在缺省的 阅读全文 »
posted @ 2019-01-29 19:16 Veritas_des_Liberty 阅读(249) 评论(0) 推荐(0) 编辑
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th 阅读全文 »
posted @ 2019-01-28 19:23 Veritas_des_Liberty 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the d 阅读全文 »
posted @ 2019-01-28 18:27 Veritas_des_Liberty 阅读(145) 评论(0) 推荐(0) 编辑
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文 »
posted @ 2019-01-28 18:23 Veritas_des_Liberty 阅读(183) 评论(0) 推荐(0) 编辑
摘要:984. String Without AAA or BBB Given two integers A and B, return any string S such that: S has length A + B and contains exactly A 'a' letters, and e 阅读全文 »
posted @ 2019-01-27 13:21 Veritas_des_Liberty 阅读(260) 评论(0) 推荐(0) 编辑
摘要:Given an array A of 0s and 1s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value. If it is possible 阅读全文 »
posted @ 2019-01-26 21:26 Veritas_des_Liberty 阅读(266) 评论(0) 推荐(0) 编辑
摘要:Given an array A of integers, for each integer A[i] we need to choose either x = -K or x = K, and add x to A[i] (only once). After this process, we ha 阅读全文 »
posted @ 2019-01-26 21:18 Veritas_des_Liberty 阅读(244) 评论(0) 推荐(0) 编辑
摘要:Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting paren 阅读全文 »
posted @ 2019-01-26 21:16 Veritas_des_Liberty 阅读(187) 评论(0) 推荐(0) 编辑
摘要:7w6:第七周程序填空题3 描述 实现一个三维数组模版CArray3D,可以用来生成元素为任意类型变量的三维数组,使得下面程序输出结果是: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29, 阅读全文 »
posted @ 2019-01-24 21:47 Veritas_des_Liberty 阅读(546) 评论(0) 推荐(0) 编辑
摘要:You want to form a target string of lowercase letters. At the beginning, your sequence is target.length '?' marks. You also have a stamp of lowercase 阅读全文 »
posted @ 2019-01-24 12:42 Veritas_des_Liberty 阅读(283) 评论(0) 推荐(0) 编辑
摘要:The i-th person has weight people[i], and each boat can carry a maximum weight of limit. Each boat carries at most 2 people at the same time, provided 阅读全文 »
posted @ 2019-01-24 11:29 Veritas_des_Liberty 阅读(230) 评论(0) 推荐(0) 编辑
摘要:Given two arrays A and B of equal size, the advantage of A with respect to B is the number of indices i for which A[i] > B[i]. Return any permutation 阅读全文 »
posted @ 2019-01-23 22:56 Veritas_des_Liberty 阅读(210) 评论(0) 推荐(0) 编辑
摘要:A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: -2: turn left 90 de 阅读全文 »
posted @ 2019-01-23 22:55 Veritas_des_Liberty 阅读(282) 评论(0) 推荐(0) 编辑
摘要:二进制文件写: 二进制文件读: 二进制文件修改: 文件拷贝: 阅读全文 »
posted @ 2019-01-22 22:40 Veritas_des_Liberty 阅读(253) 评论(0) 推荐(0) 编辑
摘要:We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggling each value in that row or c 阅读全文 »
posted @ 2019-01-22 20:19 Veritas_des_Liberty 阅读(188) 评论(0) 推荐(0) 编辑
摘要: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 bil 阅读全文 »
posted @ 2019-01-22 19:18 Veritas_des_Liberty 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Given a string S of digits, such as S = "123456579", we can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequen 阅读全文 »
posted @ 2019-01-22 19:01 Veritas_des_Liberty 阅读(342) 评论(0) 推荐(0) 编辑
摘要:N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side b 阅读全文 »
posted @ 2019-01-22 17:57 Veritas_des_Liberty 阅读(310) 评论(0) 推荐(0) 编辑
摘要:A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one p 阅读全文 »
posted @ 2019-01-10 20:55 Veritas_des_Liberty 阅读(264) 评论(0) 推荐(0) 编辑
摘要:这是一个签到题 这是一个签到题 这是一个签到题 Description 众所周知,中国矿业大学将在2019年6月1日迎来建校110周年。但是Alice想知道在哪一年中国矿业大学会迎来n周年纪念。 Input 一行,一个整数n(1<=n<=200),代表中国矿业大学n周年。 Output 在一行中输出 阅读全文 »
posted @ 2019-01-10 19:31 Veritas_des_Liberty 阅读(331) 评论(0) 推荐(0) 编辑
摘要:An integer interval [a, b] (for integers a < b) is a set of all consecutive integers from a to b, including a and b. Find the minimum size of a set S 阅读全文 »
posted @ 2019-01-09 22:36 Veritas_des_Liberty 阅读(359) 评论(0) 推荐(0) 编辑
摘要:Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has m 阅读全文 »
posted @ 2019-01-09 21:05 Veritas_des_Liberty 阅读(232) 评论(0) 推荐(0) 编辑
摘要:描述 魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 .... N ( N <= 20 )。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。 两军的司令部都会制造武士。武 阅读全文 »
posted @ 2019-01-07 12:26 Veritas_des_Liberty 阅读(536) 评论(0) 推荐(0) 编辑
摘要:描述 下面的程序输出结果是: A::Fun A::Do A::Fun C::Do 请填空: 输入无输出A::FunA::DoA::FunC::Do样例输入 样例输出 Code: Analysis: 和之前那个6w4的分析方法差不多,只不过这次是变成了指针罢了。 阅读全文 »
posted @ 2019-01-07 12:17 Veritas_des_Liberty 阅读(959) 评论(0) 推荐(0) 编辑
摘要:描述 下面程序的输出结果是: destructor B destructor A 请完整写出 class A。 限制条件:不得为 class A 编写构造函数。 输入无输出destructor Bdestructor A样例输入 样例输出 Code: Analysis: 刚开始想的是加一A的析构函数 阅读全文 »
posted @ 2019-01-07 12:11 Veritas_des_Liberty 阅读(497) 评论(0) 推荐(0) 编辑
摘要:描述 下面程序的输出结果是: A::Fun C::Do 请填空: 输入无输出A::FunC::Do样例输入 样例输出 Code: Analysis: 随便写了一下就提交了,没想到能过。 main中Call中的实参是C类的引用,但是根据输出的结果来看,Call函数中并不是传入C类的对象。就三个类,一个 阅读全文 »
posted @ 2019-01-07 12:00 Veritas_des_Liberty 阅读(457) 评论(0) 推荐(0) 编辑
摘要:描述 魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 红司令部,City 1,City 2,……,City n,蓝司令部两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值这两种 阅读全文 »
posted @ 2019-01-06 21:55 Veritas_des_Liberty 阅读(1253) 评论(1) 推荐(0) 编辑
摘要:970. Powerful Integers Given two non-negative integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0 阅读全文 »
posted @ 2019-01-06 12:43 Veritas_des_Liberty 阅读(221) 评论(0) 推荐(0) 编辑
摘要:121. Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文 »
posted @ 2019-01-05 22:35 Veritas_des_Liberty 阅读(261) 评论(0) 推荐(0) 编辑
摘要:In the world of Dota2, there are two parties: the Radiant and the Dire. The Dota2 senate consists of senators coming from two parties. Now the senate 阅读全文 »
posted @ 2019-01-05 21:50 Veritas_des_Liberty 阅读(337) 评论(0) 推荐(0) 编辑
摘要:There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A course should be ta 阅读全文 »
posted @ 2019-01-05 17:52 Veritas_des_Liberty 阅读(322) 评论(0) 推荐(0) 编辑
摘要:描述 补足程序,使得下面程序输出的结果是: ****100 输入无输出****100样例输入 样例输出 Code: 分析: 看题知道cout的是函数名,而只有输出“函数名()”才能得到与样例输出一样的结构,所以要重载”<<”,让cout输出函数指针。 阅读全文 »
posted @ 2019-01-03 12:41 Veritas_des_Liberty 阅读(267) 评论(0) 推荐(0) 编辑
摘要:描述 写一个MyString 类,使得下面程序的输出结果是: 1. abcd-efgh-abcd- 2. abcd- 3. 4. abcd-efgh- 5. efgh- 6. c 7. abcd- 8. ijAl- 9. ijAl-mnop 10. qrst-abcd- 11. abcd-qrst- 阅读全文 »
posted @ 2019-01-03 11:38 Veritas_des_Liberty 阅读(697) 评论(0) 推荐(0) 编辑
摘要:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks coul 阅读全文 »
posted @ 2019-01-03 10:06 Veritas_des_Liberty 阅读(247) 评论(0) 推荐(0) 编辑
摘要:There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the hor 阅读全文 »
posted @ 2019-01-02 22:10 Veritas_des_Liberty 阅读(231) 评论(0) 推荐(0) 编辑
摘要:Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: Exam 阅读全文 »
posted @ 2019-01-02 12:01 Veritas_des_Liberty 阅读(208) 评论(0) 推荐(0) 编辑
摘要:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l 阅读全文 »
posted @ 2019-01-02 11:27 Veritas_des_Liberty 阅读(183) 评论(0) 推荐(0) 编辑
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers 阅读全文 »
posted @ 2019-01-01 16:56 Veritas_des_Liberty 阅读(176) 评论(0) 推荐(0) 编辑
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文 »
posted @ 2019-01-01 15:51 Veritas_des_Liberty 阅读(223) 评论(0) 推荐(0) 编辑
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文 »
posted @ 2019-01-01 11:54 Veritas_des_Liberty 阅读(164) 评论(0) 推荐(0) 编辑
摘要:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文 »
posted @ 2019-01-01 11:13 Veritas_des_Liberty 阅读(161) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示