25.03.2013 Views

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

Cracking the Coding Interview - Fooo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solutions to Chapter 5 | Bit Manipulation<br />

46 }<br />

47<br />

48 public static int GetPrevious_NP(int n) {<br />

49 if (n = countZeros; i--) {<br />

71 n = SetBit(n, i, true);<br />

72 }<br />

73<br />

74 // Set zeros<br />

75 for (int i = countZeros - 1; i >= 0; i--) {<br />

76 n = SetBit(n, i, false);<br />

77 }<br />

78<br />

79 return n;<br />

80 }<br />

1 3 7<br />

<strong>Cracking</strong> <strong>the</strong> <strong>Coding</strong> <strong>Interview</strong> | Concepts and Algorithms

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!