leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit d9d6ceec6ca6e72b28c3feecf9c5693e43514778
parent d9935a53df6cb1f051f901a8bcc8176846c09c14
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed,  7 Jun 2023 16:07:28 +0200

Daily Problem

Diffstat:
AProblems/1318.cpp | 15+++++++++++++++
MREADME.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Problems/1318.cpp b/Problems/1318.cpp @@ -0,0 +1,15 @@ +class Solution { +public: + int minFlips(int a, int b, int c) { + int res = 0; + do { + int ba = a & 1, bb = b & 1; + if (c & 1) + res += !(ba | bb); + else + res += ba + bb; + a >>= 1, b >>= 1, c >>= 1; + } while (a > 0 || b > 0 || c > 0); + return res; + } +}; diff --git a/README.md b/README.md @@ -432,6 +432,7 @@ for solving problems. | 1312 | Hard | [Minimum Insertion Steps to Make a String Palindrome](Problems/1312.cpp) | | 1314 | Medium | [Matrix Block Sum](Problems/1314.cpp) | | 1315 | Medium | [Sum of Nodes with Even-Valued Grandparent](Problems/1315.cpp) | +| 1318 | Medium | [Minimum Flips to Make a OR b Equal to c](Problems/1318.cpp) | | 1319 | Medium | [Number of Operations to Make Network Connected](Problems/1319.cpp) | | 1323 | Easy | [Maximum 69 Number](Problems/1323.cpp) | | 1334 | Medium | [Find the City With the Smallest Number of Neighbors at a Threshold Distance](Problems/1334.cpp) |