D84 371. Sum of Two Integers

题目链接

371. Sum of Two Integers

题目分析

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

思路

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

最终代码

<?phpclass Solution {    /**         * @param Integer $a              * @param Integer $b                   * @return Integer                        */                            function getSum($a, $b) {                                    return array_sum([$a,$b]);                                        }                                        }
                                                                        若觉得本文章对你有用,欢迎用[爱发电](https://afdian.net/@skys215)资助。