摘要:
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions. class Solution {public: bool isValid(int* row, int curRow) { for(int i = 0; in = n; int *row = new int[n]; nqueue(row, 0); return res; }pri... 阅读全文
posted @ 2013-07-30 23:08
冰点猎手
阅读(176)
评论(0)
推荐(0)
摘要:
The n-queens puzzle is the problem of placing n queens on an n�n chessboard such that no two queens attack each other. Given an integern, return all distinct solutions to then-queens puzzle.Each solution contains a distinct board configuration of then-queens' placement, where'Q'and'. 阅读全文
posted @ 2013-07-30 22:53
冰点猎手
阅读(354)
评论(0)
推荐(0)
摘要:
Singleton 三要素:private 构造函数、 public 静态方法、 public 静态变量单实例模式的三种线程安全实现方式(C++)1 懒汉模式:即第一次调用该类实例的时候才产生一个新的该类实例,并在以后仅返回此实例。需要用锁,来保证其线程安全性:原因:多个线程可能进入判断是否已经存在实例的if语句,从而non thread safety.使用double-check来保证thread safety.但是如果处理大量数据时,该锁才成为严重的性能瓶颈。class Singleton{ private : static Singleton * m_instance... 阅读全文
posted @ 2013-07-30 09:56
冰点猎手
阅读(344)
评论(0)
推荐(0)