- 博客(8)
- 收藏
- 关注
原创 Leetcode刷题日记|算法 第一题 twoSum(Java版)
在面对这个问题时,我首先考虑了一种简单的解决方法,即使用两层循环来遍历数组,寻找满足条件的数对,在满足条件时立即返回结果,不满足则继续遍历。写一个叫twoSum的方法,传入一个整数数组nums和一个整数target,要求返回两个数字的下标,使这两个下标所对应的数相加为target。,种方法具有更低的时间复杂度(O(n)),因为哈希表的查找操作通常是O(1)。同时,LeetCode上还有一个追问在若有若无的提醒我:能否在不使用双重循环的情况下解出这道题?
2023-08-21 04:02:53
125
1
原创 [Basic] Pointer in C
Pointer is a kind of data structure, just like int, char etc., it can let code blocks in different place share a same memory. It can also make some complicate opreation possible, such as linked list.Just like define a variable, if you want to define a poin
2022-07-14 13:00:07
170
原创 习题5-7 使用函数求余弦函数的近似值
题目内容使用函数编写一个求余弦值的函数给定两个输入,误差和要求的余弦函数值使用程序要求的公式求余弦值最后一项的绝对值小于误差测试程序样例#include <stdio.h>#include <math.h>double funcos( double e, double x );int main(){ double e, x; scanf("%lf %lf", &e, &x); printf("cos(%.2
2021-12-28 19:30:15
1199
原创 [Function Question 8] PTA #C
A possible way to count a number in a string of numbers. And a small problem with another method...
2021-12-17 01:13:38
120
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人