04 2021 档案

摘要:377.组合总和 Ⅳ 呵呵,又是动态规划,啧啧啧,不会,题解没看懂;自己只能暴力跑点分; 给你一个由 不同 整数组成的数组 nums ,和一个目标整数 target 。请你从 nums 中找出并返回总和为 target 的元素组合的个数。 题目数据保证答案符合 32 位整数范围。 示例 1: 输入: 阅读全文
posted @ 2021-04-24 18:46 荣荣荣荣荣荣 阅读(51) 评论(0) 推荐(0)
摘要:368.最大整除子集 给你一个由 无重复 正整数组成的集合 nums ,请你找出并返回其中最大的整除子集 answer ,子集中每一元素对 (answer[i], answer[j]) 都应当满足: answer[i] % answer[j] == 0 ,或 answer[j] % answer[i 阅读全文
posted @ 2021-04-23 20:30 荣荣荣荣荣荣 阅读(109) 评论(0) 推荐(0)
摘要:363.矩形区域不超过 K 的最大数值和 给你一个 m x n 的矩阵 matrix 和一个整数 k ,找出并返回矩阵内部矩形区域的不超过 k 的最大数值和。 题目数据保证总会存在一个数值和不超过 k 的矩形区域。 示例 1: 输入:matrix = [[1,0,1],[0,-2,3]], k = 阅读全文
posted @ 2021-04-22 18:31 荣荣荣荣荣荣 阅读(133) 评论(0) 推荐(0)
摘要:91.解码方法 -- DP问题: 一条包含字母 A-Z 的消息通过以下映射进行了 编码 : 'A' -> 1 'B' -> 2 ... 'Z' -> 26 要 解码 已编码的消息,所有数字必须基于上述映射的方法,反向映射回字母(可能有多种方法)。例如,"11106" 可以映射为: "AAJF" ,将 阅读全文
posted @ 2021-04-21 18:53 荣荣荣荣荣荣 阅读(95) 评论(0) 推荐(0)
摘要:28.实现strStr(). 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回 -1 。 int strStr(char * haystack, char * needle){ 阅读全文
posted @ 2021-04-20 14:53 荣荣荣荣荣荣 阅读(40) 评论(0) 推荐(0)
摘要:27.移除元素 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。 不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。 int removeE 阅读全文
posted @ 2021-04-19 19:37 荣荣荣荣荣荣 阅读(54) 评论(0) 推荐(0)
摘要:#include "stdio.h" /* 5 5 2 3 2 1 2 -3 1 5 5 4 5 2 3 4 3 0 -3 2 -1 2 4 */ int main() { int a[10][10],dis[10],book[10], u[10], v[10], w[10] ,n, m; int 阅读全文
posted @ 2021-04-17 14:53 荣荣荣荣荣荣 阅读(47) 评论(0) 推荐(0)
摘要:并查集 - 擒贼先擒王 #include "stdio.h" int f[1005], n, m; void init(){ int i; for(i = 1; i <= n; i++){ f[i] = i; } } int find(int x){ if(f[x] == x)return x; e 阅读全文
posted @ 2021-04-17 14:47 荣荣荣荣荣荣 阅读(31) 评论(0) 推荐(0)
摘要:#include <stdio.h> #define Max(x, y) x > y ? x : y; #define Min(x, y) x > y ? y : x; int n, m, ans = -99999; int a[405][405], sum[405][405]; int main( 阅读全文
posted @ 2021-04-17 14:46 荣荣荣荣荣荣 阅读(126) 评论(0) 推荐(0)
摘要:求 n 的 m 次幂,然后对mod取模。 #include "stdio.h" int n, m, mod; long long quick_power(long long x, long long y){ long long sum = 1; while(y){ if(y & 1){//相当于 y 阅读全文
posted @ 2021-04-16 18:14 荣荣荣荣荣荣 阅读(38) 评论(0) 推荐(0)
摘要:一 : 题目描述 今年是2021年,请问数字1到数字2021中,出现了多少个数字6。 签到题: #include <stdio.h> int main() { int i, j, ans = 0; for(i = 1; i <= 2021; i++){ j = i; while(j){ if(j % 阅读全文
posted @ 2021-04-12 18:13 荣荣荣荣荣荣 阅读(423) 评论(0) 推荐(0)
摘要:快速排序: void quicksort(int l, int r){ if (l >= r) return ; int x = a[l + r >> 1], i = l - 1, j = r + 1; while (i < j) { while (a[++ i] < x); while (a[-- 阅读全文
posted @ 2021-04-11 13:52 荣荣荣荣荣荣 阅读(186) 评论(0) 推荐(0)