网站首页 站内搜索

搜索结果

查询Tags标签: vector,共有 875条记录
  • LeetCode刷题之洗牌算法

    LeetCode刷题之洗牌算法 1.洗牌算法的思路 共有 n 个不同的数,根据每个位置能够选择什么数,共有 n! 种组合。 题目要求每次调用 shuffle 时等概率返回某个方案,或者说每个元素都够等概率出现在每个位置中。 我们可以使用 Knuth 洗牌算法,在 O(n) 复杂度内等概率返回某…

    2021/11/22 11:10:16 人评论 次浏览
  • [LeetCode] 1255. Maximum Score Words Formed by Letters 得分最高的单词集合

    Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times). It is not necessary to …

    2021/11/22 6:09:48 人评论 次浏览
  • [LeetCode] 1255. Maximum Score Words Formed by Letters 得分最高的单词集合

    Given a list of words, list of single letters (might be repeating) and score of every character. Return the maximum score of any valid set of words formed by using the given letters (words[i] cannot be used two or more times). It is not necessary to …

    2021/11/22 6:09:48 人评论 次浏览
  • That Nice Euler Circuit——Regionals 2004 >> Asia - Shanghai——UVALive - 3263

    一笔画, 欧拉定理:平面图的顶点数,边数和面数分别为V,E和F 则V+F-E=2,所以求出顶点数V和边数E,就可以得到F=E+2-V V数组存在原来的结点和新增的结点,可能存在三线共点,需要删除重复的点#include<iostream> #include<cmath> #include<algorithm> …

    2021/11/15 23:41:01 人评论 次浏览
  • That Nice Euler Circuit——Regionals 2004 >> Asia - Shanghai——UVALive - 3263

    一笔画, 欧拉定理:平面图的顶点数,边数和面数分别为V,E和F 则V+F-E=2,所以求出顶点数V和边数E,就可以得到F=E+2-V V数组存在原来的结点和新增的结点,可能存在三线共点,需要删除重复的点#include<iostream> #include<cmath> #include<algorithm> …

    2021/11/15 23:41:01 人评论 次浏览
  • leetcode 326 矩阵中的最长递增路径

    深度优先搜索,思路不难,其中重要的是记忆化搜索,就是搜索的时候记录以当前节点为起点的最长路径的长度。贴代码1 class Solution {2 public:3 int res = 0;4 int m;5 int n;6 int longestIncreasingPath(vector<vector<int>>& matrix)…

    2021/11/15 23:14:28 人评论 次浏览
  • leetcode 326 矩阵中的最长递增路径

    深度优先搜索,思路不难,其中重要的是记忆化搜索,就是搜索的时候记录以当前节点为起点的最长路径的长度。贴代码1 class Solution {2 public:3 int res = 0;4 int m;5 int n;6 int longestIncreasingPath(vector<vector<int>>& matrix)…

    2021/11/15 23:14:28 人评论 次浏览
  • leetcode算法题--Unique Paths II

    原题链接:https://leetcode.com/problems/unique-paths-ii/ class Solution { public:int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {int m = obstacleGrid.size(), n = obstacleGrid[0].size();auto dp = vector<vector<int…

    2021/11/15 1:10:37 人评论 次浏览
  • leetcode算法题--Unique Paths II

    原题链接:https://leetcode.com/problems/unique-paths-ii/ class Solution { public:int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {int m = obstacleGrid.size(), n = obstacleGrid[0].size();auto dp = vector<vector<int…

    2021/11/15 1:10:37 人评论 次浏览
  • 1487. 保证文件名唯一

    map标记即可 注意对于某个文件名生成的结果文件名也需要标记一下class Solution { public:vector<string> ret;map<string, int> mmap;vector<string> getFolderNames(vector<string>& names) {int n = names.size();for(int i = 0; i < n…

    2021/11/14 23:45:41 人评论 次浏览
  • 1487. 保证文件名唯一

    map标记即可 注意对于某个文件名生成的结果文件名也需要标记一下class Solution { public:vector<string> ret;map<string, int> mmap;vector<string> getFolderNames(vector<string>& names) {int n = names.size();for(int i = 0; i < n…

    2021/11/14 23:45:41 人评论 次浏览
  • c++ 11标准模板(STL) std::vector (二)

    访问首尾元素 首元素 reference front(); // 可读写 const_reference front() const; // 可读,不可写返回到容器首元素的引用。 在空容器上对 front 的调用是未定义的。 参数 (无) 返回值 到首元素的引用 复杂度 常数 注意 对于容器 c ,表达式 c.front() 等价于 *c…

    2021/11/14 14:11:06 人评论 次浏览
  • c++ 11标准模板(STL) std::vector (二)

    访问首尾元素 首元素 reference front(); // 可读写 const_reference front() const; // 可读,不可写返回到容器首元素的引用。 在空容器上对 front 的调用是未定义的。 参数 (无) 返回值 到首元素的引用 复杂度 常数 注意 对于容器 c ,表达式 c.front() 等价于 *c…

    2021/11/14 14:11:06 人评论 次浏览
  • Stack&Vector源码解析

    目录1 Stack源码1.1 栈定义1.2 Stack&Vector底层存储1.3 peek()——获取栈顶的对象1.4 pop()——弹栈(出栈)1.5.push(E item)——压栈(入栈)1.6 search(Object o)1.7 empty()——容器是否为空1.8 stack是否可以用链表 1 Stack源码 前面我们已经接触过几种数据结构…

    2021/11/14 11:10:21 人评论 次浏览
  • Stack&Vector源码解析

    目录1 Stack源码1.1 栈定义1.2 Stack&Vector底层存储1.3 peek()——获取栈顶的对象1.4 pop()——弹栈(出栈)1.5.push(E item)——压栈(入栈)1.6 search(Object o)1.7 empty()——容器是否为空1.8 stack是否可以用链表 1 Stack源码 前面我们已经接触过几种数据结构…

    2021/11/14 11:10:21 人评论 次浏览
扫一扫关注最新编程教程