**leetcode笔记--4 Sum of Two Integers
question:
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
my wrong answer

错误点:
显示memory error 应该是运行较大数字时导致内存不够,所以这种方法不佳
正确答案地址:(暂时不明白)
http://blog.csdn.net/mebiuw/article/details/51788817
http://www.cnblogs.com/la0bei/p/5659829.html
http://blog.csdn.net/xtj332/article/details/6639009

重点(补充):
1 合并两个list的方法:
除了直接相加(生成新的list),还有两种方法(修改其中一个list):
用list的extend方法,L1.extend(L2),该方法将参数L2的全部元素添加到L1的尾部,例如:
>>> L1 = [1, 2, 3, 4, 5]
>>> L2 = [20, 30, 40]
>>> L1.extend(L2)
>>> L1
[1, 2, 3, 4, 5, 20, 30, 40]
用切片(slice)操作,L1[len(L1):len(L1)] = L2和上面的方法等价,例如:(此方法更加灵活)
>>> L1 = [1, 2, 3, 4, 5]
>>> L2 = [20, 30, 40]
>>> L1[len(L1):len(L1)] = L2
>>>
>>> L1
[1, 2, 3, 4, 5, 20, 30, 40]
**leetcode笔记--4 Sum of Two Integers的更多相关文章
- 【一天一道LeetCode】#371. Sum of Two Integers
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Calcula ...
- 通过位运算求两个数的和(求解leetcode:371. Sum of Two Integers)
昨天在leetcode做题的时候做到了371,原题是这样的: 371. Sum of Two Integers Calculate the sum of two integers a and b, b ...
- 【LeetCode】371. Sum of Two Integers 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 位运算 日期 题目地址:https://leetco ...
- 【leetcode】371. Sum of Two Integers
题目描述: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and - ...
- LeetCode算法题-Sum of Two Integers(Java实现)
这是悦乐书的第210次更新,第222篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第78题(顺位题号是371).计算两个整数a和b的总和,但不允许使用运算符+和 - .例 ...
- 【Leetcode 371】Sum of Two Integers
问题描述:不使用+是或-操作符进行整数的加法运算 int getSum(int a, int b); 我的思路:把整数化成二进制进行运算,注意类型是int,也就是要考虑负数.关于负数的二进制表示可见之 ...
- LeetCode之371. Sum of Two Integers
---------------------------------- 使用位运算实现加法: a^b 加不同部分(a&b)<<1 加相同部分递归相加 AC代码: public cla ...
- Leetcode 笔记 113 - Path Sum II
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
- Leetcode 笔记 112 - Path Sum
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
随机推荐
- 成都夏季招聘会IT行业缺口大!
上个周末成都的夏季招聘会在新会展中心举行,我们传智播客的专业市场调查员也深入当中.了解IT行业招聘情况,我们发如今IT软件行业专区招聘的公司特别多,可是去应聘的人却非常少.这意味着IT行业正处于供不应 ...
- bzoj 3028 生成函数
计算完后为 f(x): 根据我翻高数书,终于推倒出来了. (- ̄▽ ̄)-
- Android学习笔记_76_Android ProgressBar 进度条
android 进度条的样式 例1:(默认样式(中等圆形))Xml代码 <ProgressBar android:id="@+id/progressBar1" ...
- ubuntu16.04
原来安装的14.04快捷键冲突,又改不过来,还有就是每次从新启动,桌面就恢复原来的状态了.然后突然有一天桌面没了,我一气之下,从新安装.装好16.04还是没有桌面,我也是醉了,还好解决了.应该是我的集 ...
- excel导入到java/导出到excel
package com.test.order.config; import com.test.order.domain.HavalDO; import org.apache.poi.ss.usermo ...
- webpack中使用vue
1.安装vue cnpm i install -S 2.由于在 webpack 中,推荐使用 .vue 的文件模板文件定义组件 , 所以 ,需要安装 能解析这种文件的 loader cnpm i vu ...
- 规避Javascript多人开发函数和变量重名问题
函数和变量重名始终是一个令人头痛的问题,先讲变量吧,相信了解JS的朋友都知道,在JS中 是没有块级作用域的只有函数作用域,也就是说那些以大括号为界定符的代码块是管不住其中定义 的变量的作用域的,举例: ...
- php第五节(字符串函数和时间、日期函数)
<?php //查找字符串函数 // strpos() 查找字符第一次出现的位置 重点区分大小写 //stripos — 查找字符串首次出现的位置(不区分大小写) //strrpos — 计算指 ...
- layDate 闪现 循环一个以上会闪现
一个render一次渲染一个日期组件,这个是内置的,所以需要循环绑定, 又不能确定页面有多少个,还好layDate 提供了内置方法, //同时绑定多个 lay('.test-item').each(f ...
- 利用PHP str_replace()函数替换符合百度MIP内容标准
了解过百度MIP的同学都知道(什么?你不知道什么是百度MIP?就是移动网页加速器鸭