zoukankan      html  css  js  c++  java
  • **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]

  • 相关阅读:
    PHP+AJAX 验证码验证用户登录
    2014-05-09 总结
    2014-05-08 总结(补充)
    2014-05-08 总结
    2014-05-07 总结
    14-6-2
    php
    5-23
    PHP
    5-22
  • 原文地址:https://www.cnblogs.com/qicaide/p/5910311.html
Copyright © 2011-2022 走看看