美文网首页Leetcode题解-PHP版
Leetcode PHP题解--D84 371. Sum of

Leetcode PHP题解--D84 371. Sum of

作者: skys215 | 来源:发表于2019-06-11 09:50 被阅读0次

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]);
    }
}

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

相关文章

网友评论

    本文标题:Leetcode PHP题解--D84 371. Sum of

    本文链接:https://www.haomeiwen.com/subject/iklffctx.html