Leetcode PHP题解--D84 371. Sum of Two Integers

D84 371. Sum of Two Integers

题目连接

371. Sum of Two Integersphp

题目分析

相加给定的两个数,但不能使用+或-运算符。spa

思路

能够用二进制的与运算完成。此处用array_sum完成。.net

最终代码

<?php
class Solution {

    /** * @param Integer $a * @param Integer $b * @return Integer */
    function getSum($a, $b) {
        return array_sum([$a,$b]);
    }
}
复制代码

若以为本文章对你有用,欢迎用爱发电资助。code

相关文章
相关标签/搜索