zoukankan      html  css  js  c++  java
  • [Swift]LeetCode1318. 或运算的最小翻转次数 | Minimum Flips to Make a OR b Equal to c

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
    ➤微信公众号:山青咏芝(let_us_code)
    ➤博主域名:https://www.zengqiang.org
    ➤GitHub地址:https://github.com/strengthen/LeetCode
    ➤原文地址:https://www.cnblogs.com/strengthen/p/12185583.html
    ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
    ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

    Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).
    Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.

    Example 1:

    Input: a = 2, b = 6, c = 5
    Output: 3
    Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)
    Example 2:

    Input: a = 4, b = 2, c = 7
    Output: 1
    Example 3:

    Input: a = 1, b = 2, c = 3
    Output: 0
     

    Constraints:

    1 <= a <= 10^9
    1 <= b <= 10^9
    1 <= c <= 10^9


    给你三个正整数 a、b 和 c。

    你可以对 a 和 b 的二进制表示进行位翻转操作,返回能够使按位或运算   a OR b == c  成立的最小翻转次数。

    「位翻转操作」是指将一个数的二进制表示任何单个位上的 1 变成 0 或者 0 变成 1 。

    示例 1:

    输入:a = 2, b = 6, c = 5
    输出:3
    解释:翻转后 a = 1 , b = 4 , c = 5 使得 a OR b == c
    示例 2:

    输入:a = 4, b = 2, c = 7
    输出:1
    示例 3:

    输入:a = 1, b = 2, c = 3
    输出:0
     

    提示:

    1 <= a <= 10^9
    1 <= b <= 10^9
    1 <= c <= 10^9

  • 相关阅读:
    Qt项目时隔数月再次打开竟出现bug
    软件测试分类
    为什么要搭建自动化测试框架
    黑盒测试常用方法
    软件测试:闰年判断
    等价类划分的应用
    软件测试学习第二周:等价类划分
    软件测试的目的
    软件测试学期总结
    集成测试深度理解
  • 原文地址:https://www.cnblogs.com/strengthen/p/12185583.html
Copyright © 2011-2022 走看看