Skip to content

Instantly share code, notes, and snippets.

View ivycheung1208's full-sized avatar

Jingyi Zhang ivycheung1208

View GitHub Profile
@ivycheung1208
ivycheung1208 / 9_9.cpp
Last active August 29, 2015 14:05
CC150 9.9
/* CC150 9.9 */
// n queens
#include <iostream>
#include <vector>
using namespace std;
bool checkValid(vector<int> columns, int row) // return true if placement on (row) is valid
{
@ivycheung1208
ivycheung1208 / 5_3.cpp
Last active August 29, 2015 14:04
CC150 5.3
/* CC150 5.3
* Given a positive integer, print the next smallest and the next largest number that have the same number of
* 1 bits in their binary representation.
*/
#include <iostream>
using namespace std;
unsigned int reverse(unsigned int num, int k); // reverse from LSB through the kth bit, k < BIT_SIZE