
leetcode
aolikelili
这个作者很懒,什么都没留下…
展开
-
leetcode349
语法 //find函数的用法 //注意vector是没有find函数的,必须调用头文件algorithm #include <iostream> #include <algorithm> #include <vector> int main() { using namespace std; vector<int> vec; ...原创 2020-02-08 14:33:22 · 247 阅读 · 0 评论 -
leetcode441
思路 找规律: 1.顺着想: class Solution { public: int arrangeCoins(int n) { int result; int item=1;//每一层末尾的数 int i=2;//层数 if(n==1) return 1; while(true){ ...原创 2020-02-07 14:52:49 · 106 阅读 · 0 评论 -
leetcode989
Add to Array-Form of Integer 思路 感觉和之前做的加法问题差不多 class Solution { public: vector<int> addToArrayForm(vector<int>& A, int K) { vector<int> result; int a=A.size(...原创 2020-02-06 14:21:37 · 163 阅读 · 1 评论 -
leetcode415
思路 1.感觉和之前做过的二进制的相加很像(补齐高位从后往前一位一位加,单独讨论最高位),只不过这次是10进制而已。直接用二进制的方法来做,发现程序报了错。 代码: class Solution { public: string addStrings(string num1, string num2) { int num1_len=num1.size(); ...原创 2020-02-05 22:19:19 · 222 阅读 · 0 评论 -
leetcode258
add digits 报错 Line 14: Char 20: runtime error: signed integer overflow: 2147483640 + 8 cannot be represented in type ‘int’ (solution.cpp) public: int addDigits(int num) { int sum=0; ...原创 2020-02-04 14:49:48 · 396 阅读 · 0 评论 -
leetcode67
Add Binary 思路 自己愚蠢的思路:暴力进制转换,利用十进制相加后再次进行转换 大佬:原创 2020-02-03 15:54:17 · 223 阅读 · 0 评论 -
leetcode717
717. 1-bit and 2-bit Characters 分析: 1bit的字符只有0一个,而2bit的字符有10和11两种,题目需要判断一个字符串的最后一个0属于1bit的字符,还是2bit字符中的10. 出现问题 control reaches end of non-void function 它的意思是:控制到达非void函数的结尾。就是说一些本应带有返回值的函数到达结尾后可能并没有...原创 2020-02-03 09:24:58 · 162 阅读 · 0 评论 -
leetcode7
7. Reverse Integer 总体思路:一位数一位数地从个位拆除 其他判断:注意考虑整数溢出的情况 1.C++ 注意点:在头文件limits.h中,最大值用INT_MAX,最小值用INT_MIN class Solution { public: int reverse(int x) { int pop; int ans=0; whil...原创 2020-02-03 09:26:16 · 106 阅读 · 0 评论