Leetcode PHP problem — D84 371. Sum of Two Integers

Time:2019-9-11

D84 371. Sum of Two Integers

Title Link

371. Sum of Two Integers

Title Analysis

Add up two given numbers, but do not use the + or – operator.

thinking

It can be done with binary operations. This is done with array_sum.

Final code

<?php
class Solution {

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

If you think this article is useful to you, you are welcome to use Ai Power Generation Fund.

Recommended Today

PHP realizes UnionPay business H5 payment

UnionPay business H5 payment interface document: document address 1: H5 payment interface address: 1: Alipay payment Test address: http://58.247.0.18:29015/v1/netpay/trade/h5-pay Official address: https://api-mop.chinaums.com/ 2: UnionPay payment Test address: http://58.247.0.18:29015/v1/netpay/uac/order Official address: https://api-mop.chinaums.com/ 2: Basic parameters required by the interface The interface uses get parameters. After the interface parameters are directly put into the interface address, the […]