
数据结构与算法
以刷leetcode实战为主,总结数据结构与算法相关知识
进击的小豪
这个作者很懒,什么都没留下…
展开
-
leetcode中整数转字符的使用
leetcode上整数转字符串itoa()函数不能用,字符串转整数atoi()可以用itoa是广泛应用的非标准C语言和C++语言扩展函数,但它不是标准C/C++语言函数,所以不能在所有的编译器中使用。不过大多数的编译器(如Windows上的)通常在头文件<stdlib.h>/头文件中包含这个函数。https://leetcode-cn.com/problems/maximum-swap/solution/si-lu-xian-jiang-shu-zi-zhuan-huan-wei-zi-f.原创 2020-12-07 07:19:55 · 958 阅读 · 0 评论 -
C语言中库函数总结
常用库函数一、stdio.hsprintf#include <stdio.h>#include <math.h>int main(){ char str[80]; sprintf(str, "Pi 的值 = %f", M_PI); /* c:字符 d:十进制 s:字符串*/ puts(str); return(0);}二、stdlib.hatoi范围:0~9,大于这个范围,例如 ‘a’ = 97 ‘A’ = 65,返回值原创 2020-11-20 01:16:36 · 907 阅读 · 0 评论 -
结构体
结构体定义基础定义:struct User { int Id; int followeeId; struct User* next;}typedef定义:typedef struct User { int Id; int followeeId; struct User* next;} AnotherUser;AnotherUser相当于struct User的别名,因为在定义结构体指针next时,代码还没编译到AnotherUser,所以在定义结构体指针时,需要将结构体原创 2020-11-15 16:18:20 · 246 阅读 · 0 评论 -
数学
数学整数反转https://leetcode-cn.com/problems/reverse-integer/submissions/ while(x != 0) { count = count * 10 + x % 10; x = x / 10; }https://www.cnblogs.com/x_wukong/p/5675795.html原创 2020-11-05 08:28:12 · 197 阅读 · 0 评论 -
字符串
字符串题目链接:https://leetcode-cn.com/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/submissions/此题使用了string.h头文件中的memcpy()、strcat()函数,可参考菜鸟教程熟悉string.h中的函数,以及stdlib.h中的malloc等函数void *memcpy(void str1, const void str2, size_t n)str1 --指向用于存储复制内容的目标数组,类型强制转换为 voi原创 2020-10-26 00:08:18 · 197 阅读 · 1 评论 -
leetcode简单题题型分类
leetcode刷题- tag: 栈、排序、位运算、递归、队列、数组、哈希表、链表、数学、双指针、字符串* 栈&队列:https://leetcode-cn.com/problems/implement-queue-using-stacks-lcci/* 排序:* 递归:* 数组:https://leetcode-cn.com/problems/running-sum-of-1d-array/solution/runtime error: load of null pointer of原创 2020-10-25 22:02:42 · 322 阅读 · 0 评论 -
一维数组
一维数组题目链接:https://leetcode-cn.com/problems/running-sum-of-1d-array/出现错误stack overflow有一个int型空指针问题解决本题逻辑并不困难,但是总是会出现奇怪的报错:报错是因为入参当中有个*returnSize,不可以把它当作输出数组使用,这是因为leetcode会输出一个代表数组长度的引用。报错是因为定义输出数组时,并不知道数组的长度,因此需要使用动态分配内存空间的方法来定义数组空间。...原创 2020-10-22 00:21:33 · 216 阅读 · 0 评论