DSA Sheet - Day 34 Miscellaneous

DSA Sheet Day 34 - Miscellaneous Problems | ExpertFunda

🧩 DSA Sheet – Day 34: Miscellaneous

This section covers mixed problems involving bit manipulation, recursion, simulation, and observations. These questions are often used to test your problem-solving intuition.

📊 Progress Tracker

Progress: 0 / 5 Completed

Done Problem Practice Level Companies
Power Set Solve Medium Google, Uber
Maximum XOR of Two Numbers Solve Medium Amazon, Google
Power of Two Solve Easy Apple, TCS
XOR Beauty of Array Solve Medium Amazon
Watering Plants II Solve Medium Amazon

🧠 Key Approaches

  • Power Set: Backtracking OR bitmasking
  • Maximum XOR: Trie OR greedy bit manipulation
  • Power of Two: Bit trick → n & (n-1)
  • XOR Beauty: Reduce expression using XOR properties
  • Watering Plants: Two pointers + simulation

⚡ Quick Cheatsheet

Power of Two


return n > 0 && (n & (n - 1)) == 0;
    

Power Set (Bitmask)


for(int i = 0; i < (1 << n); i++){
  for(int j = 0; j < n; j++){
    if(i & (1 << j)){
      // include nums[j]
    }
  }
}
    

Maximum XOR (Concept)


// try to match opposite bit (1 ↔ 0)
// maximize XOR using Trie
    

🔥 Pro Tip

These problems test your thinking, not memorization:
  • Use bit manipulation wherever possible
  • Look for mathematical simplifications
  • Simulate when logic is complex
If you understand XOR deeply → many problems become easy.
Continue Reading →