上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: 28.实现strStr(). 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回 -1 。 int strStr(char * haystack, char * needle){ 阅读全文
posted @ 2021-04-20 14:53 荣荣荣荣荣荣 阅读(38) 评论(0) 推荐(0)
摘要: 27.移除元素 给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。 不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。 int removeE 阅读全文
posted @ 2021-04-19 19:37 荣荣荣荣荣荣 阅读(53) 评论(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 荣荣荣荣荣荣 阅读(46) 评论(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 荣荣荣荣荣荣 阅读(125) 评论(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 荣荣荣荣荣荣 阅读(37) 评论(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 荣荣荣荣荣荣 阅读(422) 评论(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 荣荣荣荣荣荣 阅读(185) 评论(0) 推荐(0)
摘要: 全球变暖 你有一张某海域 N × N像素的照片,”.”表示海洋、”#”表示陆地,如下所示: ....... .##.... .##.... ....##. ..####. ...###. ....... 其中”上下左右”四个方向上连在一起的一片陆地组成一座岛屿,例如上图就有 2 座岛屿。 由于全球变 阅读全文
posted @ 2021-03-31 17:46 荣荣荣荣荣荣 阅读(63) 评论(0) 推荐(0)
摘要: 四平方和 四平方和定理,又称为拉格朗日定理: 每个正整数都可以表示为至多 4 个正整数的平方和。 如果把 0 包括进去,就正好可以表示为 44 个数的平方和。 比如: 5 = 0 * 0 + 0 * 0 +1 * 1 + 2 * 2; 对于一个给定的正整数,可能存在多种平方和的表示法。 要求你对 4 阅读全文
posted @ 2021-03-30 15:47 荣荣荣荣荣荣 阅读(514) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 下一页