C
ylemfei
这个作者很懒,什么都没留下…
展开
-
找位置
题目链接:https://www.nowcoder.com/practice/e3b2cc44aa9b4851bdca89dd79c53150?tpId=69&tqId=29675&tPage=2&ru=/kaoyan/retest/11002&qru=/ta/hust-kaoyan/question-ranking代码如下:#include<iost...原创 2019-01-05 10:07:29 · 233 阅读 · 0 评论 -
买卖股票的最佳时机
题目链接:https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/一开始的想法是:对于第i天,先找出前i-1天的最小值,然后相减,找出最大值就好了。代码是:int maxProfit(int* prices, int pricesSize) { int *preMin = (int *)malloc(size...原创 2019-01-05 17:00:16 · 125 阅读 · 0 评论 -
453. 最小移动次数使数组元素相等
题目链接:https://leetcode-cn.com/problems/minimum-moves-to-equal-array-elements/其实感觉这里的“移动”,应该改成“选定”,比如[1,2,3]->[2,3,3],是“选定”最后一个,其他的n-1个加1得到思路是参考别人的。。自己想的有点复杂因为“选定”的元素不变,其他的加1,相当于“选定”的元素减1,其他的不变。...原创 2019-01-08 11:14:00 · 232 阅读 · 1 评论 -
C++ stringstream(用C++做文件操作等会用到)
参考文献:https://blog.csdn.net/jllongbell/article/details/79092891C语言里面常用的字符串和数字转换函数是sscanf和sprintfspritf (直观理解:往字符串中写)sprintf函数原型为 int sprintf(char *str, const char *format, …)作用是格式化字符串,具体功能如下所示: ...原创 2019-07-22 09:33:00 · 1175 阅读 · 0 评论