1318. Minimum Flips to Make a OR b Equal to c Medium
1/**
2 * [1318] Minimum Flips to Make a OR b Equal to c
3 *
4 * 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).<br />
5 * Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.
6 *
7 *
8 * Example 1:
9 *
10 * <img alt="" src="https://assets.leetcode.com/uploads/2020/01/06/sample_3_1676.png" style="width: 260px; height: 87px;" />
11 *
12 *
13 * Input: a = 2, b = 6, c = 5
14 * Output: 3
15 * Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)
16 *
17 * Example 2:
18 *
19 *
20 * Input: a = 4, b = 2, c = 7
21 * Output: 1
22 *
23 *
24 * Example 3:
25 *
26 *
27 * Input: a = 1, b = 2, c = 3
28 * Output: 0
29 *
30 *
31 *
32 * Constraints:
33 *
34 *
35 * 1 <= a <= 10^9
36 * 1 <= b <= 10^9
37 * 1 <= c <= 10^9
38 *
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c/
43// discuss: https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48 pub fn min_flips(a: i32, b: i32, c: i32) -> i32 {
49 0
50 }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57 use super::*;
58
59 #[test]
60 fn test_1318() {
61 }
62}
63
Back
© 2025 bowen.ge All Rights Reserved.