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

D84 371. Sum of Two Integers

题目链接

371. Sum of Two Integers

题目分析

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

思路

可以用二进制的与运算完成。此处用array_sum完成。

最终代码

<?php
class Solution {

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

若觉得本文章对你有用,欢迎用爱发电资助。

转载于:https://juejin.im/post/5cff09abe51d45105e02129a

猜你喜欢

转载自blog.csdn.net/weixin_34320724/article/details/93169719