Find Y Value

Problem Overview

  • Find a binary string y, same length as x, that maximizes the XOR result with x while using at most maxSet set bits.
  • Input: bits (length of x and y), maxSet (limit of 1s in y), and x (binary); Output: y as a binary string of length bits with leading zeros allowed; constraints unspecified.
  • Focuses on bitwise optimization in systems/digital logic contexts where maximizing XOR under limits is relevant.
  • From Ibm interviews; a coding interview problem and common interview question on binary strings and XOR.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: