码迷,mamicode.com
首页 >  
搜索关键字:r语言中的 vector    ( 11651个结果
//把数组排成最小的数
//把数组排成最小的数#include "stdafx.h"using namespace std;#include <string>#include <vector>#include <map>#include<algorithm>class Solution{public: string fin ...
分类:编程语言   时间:2020-04-19 17:57:25    阅读次数:72
C++ 素数对猜想
我的解法是先将2到n的所有素数全部列出来,再计算。将全部的素数列出来用了一个叫“埃拉托色尼筛法”的方法。 算法参照这里:https://www.sohu.com/a/252674565_614593 1 #include <iostream> 2 #include <vector> 3 #inclu ...
分类:编程语言   时间:2020-04-19 17:34:37    阅读次数:71
667. Beautiful Arrangement II
问题: 给定一个n,有数组1~n, 排列该数组,使得数组两两元素之间的差值有k种。 Example 1: Input: n = 3, k = 1 Output: [1, 2, 3] Explanation: The [1, 2, 3] has three different positive int ...
分类:其他好文   时间:2020-04-19 14:58:40    阅读次数:57
// 二维数组查找
// 二维数组查找#include "stdafx.h"using namespace std;#include <string>#include <vector>class Solution {public: bool Find(int target, vector<vector<int> > a ...
分类:编程语言   时间:2020-04-19 14:55:49    阅读次数:39
剑指offer:最小k个数
题目描述 输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。 代码: 1.普通人的大顶堆解法 class Solution { public: vector<int> GetLeastNumbers_Solution(vecto ...
分类:其他好文   时间:2020-04-19 12:51:54    阅读次数:53
FJOI2016 建筑师 和 CF960G Bandit Blues
过了一年来看,这道题还是很妙。 FJOI2016 建筑师 小 Z 是一个很有名的建筑师,有一天他接到了一个很奇怪的任务:在数轴上建 $n$ 个建筑,每个建筑的高度是 $1$ 到 $n$ 之间的一个整数。 小 Z 有很严重的强迫症,他不喜欢有两个建筑的高度相同。另外小 Z 觉得如果从最左边(所有建筑都 ...
分类:其他好文   时间:2020-04-19 11:08:48    阅读次数:60
p145 支持随机获取元素的集合(leetcode 380)
一:解题思路 二:完整代码示例 (C++版和Java版) C++: class RandomizedSet { private: map<int, int> m_map; vector<int> m_data; public: /** Initialize your data structure h ...
分类:其他好文   时间:2020-04-18 22:59:21    阅读次数:69
反转链表
#include "stdafx.h"#include <string>using namespace std;#include <vector>#include <stack>typedef struct tag_listnode{ int data; struct tag_listnode *n ...
分类:其他好文   时间:2020-04-18 21:19:56    阅读次数:50
697. Degree of an Array
Problem : Given a non empty array of non negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elemen ...
分类:其他好文   时间:2020-04-18 18:27:07    阅读次数:49
45. 跳跃游戏 II
1 //BFS + 贪心 2 //维护一个区间[l,r],在这里面可以找到能够跳到最大位置,step++,同时更新l,r 3 class Solution 4 { 5 public: 6 int jump(vector<int>& nums) 7 { 8 if(nums.size() < 2) re ...
分类:其他好文   时间:2020-04-18 15:51:53    阅读次数:45
11651条   上一页 1 ... 84 85 86 87 88 ... 1166 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!