From cb5f7c4f986ed7282fcb2e74f123706a033ba248 Mon Sep 17 00:00:00 2001 From: Pontus Magnusson Date: Sun, 21 Aug 2022 00:16:01 +0200 Subject: [PATCH] Add csharp solution for 371 Sum of two integers --- csharp/371-Sum-Of-Two-Integers.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 csharp/371-Sum-Of-Two-Integers.cs diff --git a/csharp/371-Sum-Of-Two-Integers.cs b/csharp/371-Sum-Of-Two-Integers.cs new file mode 100644 index 000000000..6779682e1 --- /dev/null +++ b/csharp/371-Sum-Of-Two-Integers.cs @@ -0,0 +1,11 @@ +public class Solution { + public int GetSum(int a, int b) { + while (b != 0) + { + var carry = a & b; + a = a ^ b; + b = carry << 1; + } + return a; + } +} \ No newline at end of file