27.10.2014 Views

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

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.

<strong>Solutions</strong> 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 <strong>and</strong> Algorithms

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

Saved successfully!

Ooh no, something went wrong!