leetcode
DreamXY12
在读研究生一枚
展开
-
53.Maximum Subarray
这是leetcode上简单难度的题目,我写出来后运行时间900 ms,内存占用:13.2 MB,这说明我的代码不是特别好。但我还是把他粘贴出来,作为一个高考数学都没有上80的人来说,做leetcode就TM是一种煎熬QAQ。具体代码如下:class Solution {public: int maxSubArray(vector<int>& nums) { int max2=0; int max3=0; int sum=0;原创 2021-05-17 15:39:26 · 93 阅读 · 0 评论 -
Swap Nodes in Pairs-LeetCode
这个leetCode题目难度虽然是中等的,但实现起来还是挺简单的,我直接贴代码,里面都有注释,我解释的很清楚了。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {}原创 2021-05-13 17:16:14 · 112 阅读 · 0 评论 -
LeetCode-Add Two Numbers题目解析
这是个在leetcode上中等难度的题目,我搞了好半天,最终以一种原始的方法弄出来了,我把它贴出来供大家参考,我是一个研究生,没有实际的工作经验,写的不好请大家多多包涵。看题目:You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse order, and each of their nodes contains a single ...原创 2021-05-05 22:01:44 · 203 阅读 · 0 评论