01 2019 档案
发表于 2019-01-31 22:50阅读:438评论:0推荐:0
摘要: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
阅读全文 »
发表于 2019-01-31 22:37阅读:255评论: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 <
阅读全文 »
发表于 2019-01-30 23:43阅读:384评论: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
阅读全文 »
发表于 2019-01-30 23:04阅读:358评论: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
阅读全文 »
发表于 2019-01-30 22:09阅读:161评论: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
阅读全文 »
发表于 2019-01-29 23:35阅读:602评论:0推荐:0
摘要:描述 写一个程序完成以下命令:new id ——新建一个指定编号为id的序列(id<10000)add id num——向编号为id的序列加入整数nummerge id1 id2——合并序列id1和id2中的数,并将id2清空unique id——去掉序列id中重复的元素out id ——从小到大输
阅读全文 »
发表于 2019-01-29 23:33阅读:362评论: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,但是这种方法,
阅读全文 »
发表于 2019-01-29 21:26阅读:244评论:0推荐:0
摘要:greater 的应用 list 有两个sort成员函数 void sort(); 将list中的元素按 “<” 规定的比较方法升序排列。 template void sort (Compare op); 将list中的元素按 op 规定的比较方法升序排列。即要比较x,y 大小时,看 op(
阅读全文 »
发表于 2019-01-29 19:16阅读:249评论:0推荐:0
摘要:STL中“大”“小” 的概念: 关联容器内部的元素是从小到大排序的 有些算法要求其操作的区间是从小到大排序的,称为“有序区间算法”例:binary_search 有些算法会对区间进行从小到大排序,称为“排序算法”例: sort 还有一些其他算法会用到“大”,“小”的概念使用STL时,在缺省的
阅读全文 »
发表于 2019-01-28 19:23阅读:163评论: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
阅读全文 »
发表于 2019-01-28 18:27阅读:145评论: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
阅读全文 »
发表于 2019-01-28 18:23阅读:183评论: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
阅读全文 »
发表于 2019-01-27 13:21阅读:260评论: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
阅读全文 »
发表于 2019-01-26 21:26阅读:266评论: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
阅读全文 »
发表于 2019-01-26 21:18阅读:244评论: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
阅读全文 »
发表于 2019-01-26 21:16阅读:187评论: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
阅读全文 »
发表于 2019-01-24 21:47阅读:546评论: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,
阅读全文 »
发表于 2019-01-24 12:42阅读:283评论: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
阅读全文 »
发表于 2019-01-24 11:29阅读:230评论: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
阅读全文 »
发表于 2019-01-23 22:56阅读:210评论: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
阅读全文 »
发表于 2019-01-23 22:55阅读:282评论: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
阅读全文 »
发表于 2019-01-22 22:40阅读:253评论:0推荐:0
摘要:二进制文件写: 二进制文件读: 二进制文件修改: 文件拷贝:
阅读全文 »
发表于 2019-01-22 20:19阅读:188评论: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
阅读全文 »
发表于 2019-01-22 19:18阅读:207评论: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
阅读全文 »
发表于 2019-01-22 19:01阅读:342评论: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
阅读全文 »
发表于 2019-01-22 17:57阅读:310评论: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
阅读全文 »
发表于 2019-01-10 20:55阅读:264评论: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
阅读全文 »
发表于 2019-01-10 19:31阅读:331评论:0推荐:0
摘要:这是一个签到题 这是一个签到题 这是一个签到题 Description 众所周知,中国矿业大学将在2019年6月1日迎来建校110周年。但是Alice想知道在哪一年中国矿业大学会迎来n周年纪念。 Input 一行,一个整数n(1<=n<=200),代表中国矿业大学n周年。 Output 在一行中输出
阅读全文 »
发表于 2019-01-09 22:36阅读:359评论: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
阅读全文 »
发表于 2019-01-09 21:05阅读:232评论: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
阅读全文 »
发表于 2019-01-07 12:26阅读:536评论:0推荐:0
摘要:描述 魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 .... N ( N <= 20 )。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。 两军的司令部都会制造武士。武
阅读全文 »
发表于 2019-01-07 12:17阅读:959评论:0推荐:0
摘要:描述 下面的程序输出结果是: A::Fun A::Do A::Fun C::Do 请填空: 输入无输出A::FunA::DoA::FunC::Do样例输入 样例输出 Code: Analysis: 和之前那个6w4的分析方法差不多,只不过这次是变成了指针罢了。
阅读全文 »
发表于 2019-01-07 12:11阅读:497评论:0推荐:0
摘要:描述 下面程序的输出结果是: destructor B destructor A 请完整写出 class A。 限制条件:不得为 class A 编写构造函数。 输入无输出destructor Bdestructor A样例输入 样例输出 Code: Analysis: 刚开始想的是加一A的析构函数
阅读全文 »
发表于 2019-01-07 12:00阅读:457评论:0推荐:0
摘要:描述 下面程序的输出结果是: A::Fun C::Do 请填空: 输入无输出A::FunC::Do样例输入 样例输出 Code: Analysis: 随便写了一下就提交了,没想到能过。 main中Call中的实参是C类的引用,但是根据输出的结果来看,Call函数中并不是传入C类的对象。就三个类,一个
阅读全文 »
发表于 2019-01-06 21:55阅读:1253评论:1推荐:0
摘要:描述 魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市。 红司令部,City 1,City 2,……,City n,蓝司令部两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion、wolf 五种。每种武士都有编号、生命值这两种
阅读全文 »
发表于 2019-01-06 12:43阅读:221评论:0推荐: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
阅读全文 »
发表于 2019-01-05 22:35阅读:261评论: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
阅读全文 »
发表于 2019-01-05 21:50阅读:337评论: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
阅读全文 »
发表于 2019-01-05 17:52阅读:322评论: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
阅读全文 »
发表于 2019-01-03 12:41阅读:267评论:0推荐:0
摘要:描述 补足程序,使得下面程序输出的结果是: ****100 输入无输出****100样例输入 样例输出 Code: 分析: 看题知道cout的是函数名,而只有输出“函数名()”才能得到与样例输出一样的结构,所以要重载”<<”,让cout输出函数指针。
阅读全文 »
发表于 2019-01-03 11:38阅读:697评论: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-
阅读全文 »
发表于 2019-01-03 10:06阅读:247评论: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
阅读全文 »
发表于 2019-01-02 22:10阅读:231评论: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
阅读全文 »
发表于 2019-01-02 12:01阅读:208评论: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
阅读全文 »
发表于 2019-01-02 11:27阅读:183评论: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
阅读全文 »
发表于 2019-01-01 16:56阅读:176评论: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
阅读全文 »
发表于 2019-01-01 15:51阅读:223评论:0推荐:0
摘要:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The
阅读全文 »
发表于 2019-01-01 11:54阅读:164评论: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
阅读全文 »
发表于 2019-01-01 11:13阅读:161评论: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
阅读全文 »