Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to add LeetCode without addition, subtraction, multiplication and division

Shulou Source: shulou.com Published: 2022-06-01 13:03:43 09月24日 Update

This article will explain in detail how to add LeetCode without addition, subtraction, multiplication and division. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Brief introduction of the problem.

Write a function to find the sum of two integers, requiring that the four operation symbols of "+", "-", "*" and "/" should not be used in the function body.

2, example

Example:

Input: a = 1, b = 1 output: 2

Tip:

A, b may be negative or 0 will not overflow 32-bit integers

3, the train of thought of solving the problem

Use existing api to solve the problem

4, problem solving procedure

Public class AddTest {public static void main (String [] args) {int a = 1; int b = 1; int add = add (a, b); System.out.println ("add =" + add);}

Public static int add (int a, int b) {return Math.addExact (a, b);}}

5. Picture version of the problem solving program.

This is the end of this article on "how to add, subtract, multiply and divide LeetCode". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Articles problem solutions addition subtraction multiplication and division no addition functions integers more examples programs good practical four operations two sum content four pictures ideas articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn Xiaomi Linux Apple