ICode9

精准搜索请尝试: 精确搜索
  • 力扣练习——28 拼接最大数2022-07-18 11:00:18

    1.问题描述 给定长度分别为 m 和 n 的两个数组,其元素由 0-9 构成,表示两个自然数各位上的数字。现在从这两个数组中选出 k (k <= m + n) 个数字拼接成一个新的数,要求从同一个数组中取出的数字保持其在原数组中的相对顺序。 求满足该条件的最大数。结果返回一个表示该最大数的长度为

  • Leetcode 6121 日志2022-07-17 15:39:44

    class Solution { public: static bool mycomp(pair<string, int> a, pair<string, int> b) { return a.first < b.first; } vector<int> smallestTrimmedNumbers(vector<string>& nums, vector<vector<int>>

  • Fizz Buzz2022-07-17 15:32:50

    给你一个整数 n ,找出从 1 到 n 各个整数的 Fizz Buzz 表示,并用字符串数组 answer(下标从 1 开始)返回结果,其中: answer[i] == "FizzBuzz" 如果 i 同时是 3 和 5 的倍数。answer[i] == "Fizz" 如果 i 是 3 的倍数。answer[i] == "Buzz" 如果 i 是 5 的倍数。answer[i] == i (以字符串形

  • C++ vector的用法2022-07-14 23:03:30

    取自CSDN大佬:一个傻傻的程序员 https://blog.csdn.net/glsjh/article/details/123467985?ops_request_misc=&request_id=&biz_id=102&utm_term=vector+c+++%E7%94%A8%E6%B3%95&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-123467

  • cpp类型双关2022-07-14 19:31:34

    类型双关 C标准中的未定义行为,对于一个变量分配的内存,我们绕过c++的类型系统,原始的看待这块内存,将它按照另外的类型解读。 代码示例 struct Vector { int x, y; int* GetPosition() { return &x; //将Vector双关为一维数组 } } Vector v = {100, 200}; //传统写法 in

  • 700 · 杆子分割2022-07-13 00:00:53

    描述 给一个 n 英寸长的杆子和一个包含所有小于 n 的尺寸的价格. 确定通过切割杆并销售碎片可获得的最大值.   样例 样例1 输入: [1, 5, 8, 9, 10, 17, 17, 20] 8 输出:22 解释: 长度 | 1 2 3 4 5 6 7 8 ----------------------------------

  • 力扣练习——18 前 K 个高频元素2022-07-12 22:02:48

    1.问题描述 给定一个非空的整数数组,返回其中出现频率前 k 高的元素。   示例 1: 输入: nums = [1,1,1,2,2,3], k = 2 输出: [1,2] 示例 2: 输入: nums = [1], k = 1 输出: [1]   说明: 你可以假设给定的 k 总是合理的,且 1 ≤ k ≤ 数组中不相同的元素的个数。 你的算法的时间复杂

  • C++ push方法与push_back方法 浅析2022-07-12 08:31:25

    摘要】 push与push_back是STL中常见的方法,都是向数据结构中添加元素。初识STL,对于添加元素的方法以产生混淆,这里暂对两种方法作出比较分析。此外,本文还将简述push对应的stack与queue系列,常见方法的介绍,以及与push_back相对应的vector系列常见方法介绍。详见下文。 list 也是使用 p

  • 力扣 题目88- 合并两个有序数组2022-07-11 16:04:14

    题目 题解 这种题 一看 我们直接先从后面向前想 很容易能想到我们谁大取谁 这里的向后 分别是指m n 以及遍历的nums1->p= m+ n - 1; nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3 一开始  nums1 [m]=3 nums2[n] =6 所以nums1 [p]=6;->p--;n-- ->1 2 3 0 0 6 nums1 [

  • 牛客 主持人调度(二)2022-07-11 09:32:51

    思路: 贪心。 实现: 1 class Solution { 2 public: 3 /** 4 * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 5 * 6 * 计算成功举办活动需要多少名主持人 7 * @param n int整型 有n个活动 8 * @param startEnd int

  • ABC-2592022-07-10 15:01:15

    D - Circumferences(简单计算几何) Problem 二维平面上给定两个点\(s,t\)和若干个圆,问是否可以从\(s\)只经过圆边到达\(t\) \(1\le N\le 3000\) Solve 把每个圆之间的相交或相切关系转换成两个圆可达,于是就变成了一个图论问题,给定起点和终点,问是否可以从起点到终点,一次\(bfs\)就可

  • LeetCode Median of Two Sorted Arrays 排序2022-07-10 03:00:08

    Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be \(O(\log (m+n))\). Solution 简单排序即可: 点击查看代码 class Solution { private: vector<int> vc;

  • LeetCode Two Sum Map映射2022-07-10 02:31:15

    Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer

  • Codeforces 1286F - Harry The Potter(折半搜索+DP)2022-07-09 09:03:42

    Codeforces 题面传送门 & 洛谷题面传送门 一道代码 1k 题,然而我在传引用方面犯了一个智障错误导致我从昨天晚上调到今天早上…… 首先考虑在二类操作对应的 \(i,j\) 之间连边,那么显然不会成环,否则可以调整全用 \(1\) 类操作不会更劣。证明很 easy。而显然假设 \(C\) 为我们连出来

  • LeetCode/最长斐波那契子序列的长度2022-07-09 02:32:43

    给定一个严格递增的正整数数组形成序列 arr ,找到 arr 中最长的斐波那契式的子序列的长度。如果一个不存在,返回0 1. 暴力法 先用哈希表记录,再二重循环遍历转移,会存在重复遍历 class Solution { public: int lenLongestFibSubseq(vector<int>& arr) { unordered_set<int

  • 第二周博客2022-07-08 19:04:50

    学习了idea中HelloWorld的实现以及模块操作等功能,同时对JAVA中数组定义,动态初始化,数组元素访问有了一定程度的理解; 同时在完成小学期的任务的过程中,对C++有了更深层次的理解,学习到了vector,链表等新知识,同时对制作程序的操作目录进行了学习。

  • 474. 一和零 (三维01背包)2022-07-06 00:31:59

      难度中等754 给你一个二进制字符串数组 strs 和两个整数 m 和 n 。 请你找出并返回 strs 的最大子集的长度,该子集中 最多 有 m 个 0 和 n 个 1 。 如果 x 的所有元素也是 y 的元素,集合 x 是集合 y 的 子集 。   示例 1: 输入:strs = ["10",

  • Leetcode weekly contest 3002022-07-05 16:35:04

    1.解密消息 解题思路: 我们用一个哈希表来记录下我们的这些第一次字符的出现位置,然后在遍历需要解密的字符串,利用已经记录好的哈希表来进行解密。 Tag: 哈希表 Code: class Solution { public: string decodeMessage(string key, string message) { unordered_map<ch

  • c++ vector 大数加法2022-07-03 21:03:10

    vector<char> add(vector<char>& A, vector<char>& B) { if (A.size() < B.size()) return add(B, A); vector<char> C; int t = 0; for (int i = 0; i < A.size(); i++) { t += A[i]; if (i < B.

  • 每日一问--ArrayList、LinkedList、Vector者的异同2022-07-03 17:35:38

    ArrayList、LinkedList、Vector者的异同 相同点:     三个类都是实现了List接口;     存储数据的特点相同:存储序的、可重复的数据. 不同点: ArrayList:作为List接口的主要实现类;线程不安全的,效率高;底层使用Object[] elementData存储.   LinkedList:对于频繁的插入、删除

  • 0702训练题目题解2022-07-03 13:02:51

    [LC2300] class Solution { public: using LL = long long; vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) { //sort(spells.begin(), spells.end()); sort(potions.begin(

  • 八大排序2022-07-03 13:02:15

    八大排序   1.冒泡排序 class Solution {public:    vector<int> sortArray(vector<int>& nums) {        int n=nums.size();        int flag=0;        for(int i=0;i<n-1;n--){            for(int j=0;j<n-1;j++){                if(nums[j]>n

  • LeetCode/下一个更大元素2022-07-03 04:00:09

    nums1 中数字 x 的 下一个更大元素 是指 x 在 nums2 中对应位置 右侧 的 第一个 比 x 大的元素。 给你两个 没有重复元素 的数组 nums1 和 nums2 ,下标从 0 开始计数,其中nums1 是 nums2 的子集。 对于每个 0 <= i < nums1.length ,找出满足 nums1[i] == nums2[j] 的下

  • 2022-7-12022-07-01 12:03:15

    题目链接:https://leetcode.cn/problems/different-ways-to-add-parentheses/ 个人题解: 首先是DFS深搜来解决 开一个数组,来存数字和字符,取出数字采用双指针即可 DFS递归两边,设置左右两个参数,分别计算 代码: class Solution { public: vector<string> res; vector<int> di

  • 算法篇2022-07-01 12:01:16

    我是一个个人小开发,博客只供自己记录一些技能,以免忘记。勿喷         快速排序实现 1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 7 void Quicksort(vector<int> &q,int l,int r) 8 { 9 if( l >= r) return; 10 int i = l

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有