酸甜苦辣复何求
酸甜苦辣复何求
全部文章
分类
题解(3)
归档
标签
去牛客网
登录
/
注册
酸甜苦辣复何求的博客
全部文章
(共38篇)
题解 | #三角形最小路径和#
/** 动态规划思想,求每个位置上最小的路径,如果是经过triangle[n][0]上面的,那么到他只能从triangle[n-1][0]下来, 经过triangle[n][1~i],只能从它头上两个顶点来,那么找到最小值就行了, 从而得到最后一row,取其中最小值即可。 * 代码中的类名、方法名...
2024-03-20
0
211
题解 | #明明的随机数#
#include <stdio.h> //数组去重+冒泡排序 int main() { int array[1000] = {0}; int times; scanf("%d",×); for(int i =0;i<times;i++){ scanf(...
2024-03-15
0
216
题解 | #两个链表的第一个公共结点#
import java.util.*; /* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } }*/ publi...
2024-02-29
0
270
题解 | #ranko的手表#
//自己没想出来,抄c排名第一个的 //方法:0 - 23*60+59,去试试符合 条件第一次手表格式否, 和第二次条件 //之前卡在先确定hour第一位,再比对第二位,再比对第三位上,因为情况太多(其实也可以实现),直接放弃。 //符合就进入候选数组 //遍历比对得到相差最小值,最大值 #inc...
2023-12-07
0
278
题解 | #[NOIP2001]装箱问题#
//01装箱 ,至于为什么用二维矩阵,我也不知道为什么 #include <stdarg.h> #include <stdio.h> #include<malloc.h> void minClose(int *arr,int count, int quant...
2023-11-14
0
221
题解 | #快速幂#
#include <stdio.h> //两个关键点, (a*b)mod q = (a mod q)*(b mod q) mod q; // a^n (n>=2) = a^n/2 * a^n/2 (单数情况见代码) unsigned long long q...
2023-09-20
0
228
题解 | #相差不超过k的最多数#
#我被时间,空间卡了好久两个方面,1.用时间复杂度最小的排序算法。2.排序好后,再双指针遍历一遍。时间复杂度(n),原来的是n平方。答案在最后。#include <stdio.h>#include<malloc.h>// 先排序,然后两个指针从中间往两边移动,直到指针所指的只...
2023-08-15
0
335
题解 | #三角形最小路径和#
首先,我一看,这个题目简单,怎么是中等难度呢?马上奋笔疾书思路就是从上到下,能选最小就选最小,只走一次。int minTrace(int** triangle, int triangleRowLen, int* triangleColLen ) { // write code here ...
2023-08-08
0
327
题解 | #从中序与后序遍历序列构造二叉树#
/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */这不是我自己写出来的,看了别人的方法,然后理解 了 /** * 代码中的类名、方法名、参数名已经指定...
2023-03-27
0
318
题解 | #二分查找-I#
二分法,我用了三个指针,其中最后需要考虑start end两个位置。/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型一维数组 * @param numsLen int nums数组长度 * @param ...
2023-03-23
0
290
首页
上一页
1
2
3
4
下一页
末页