原创 單例的Double check問題和CPU動態調度共存時的線程安全問題。

改編自《程序員的自我修養》主要是爲了記錄和整理一下自己的思路。 一種典型的單例的實現方式是: volatile T* pInstance = NULL; T* getInstance(){ if(!pInstance){ lock

原创 對ACM的一點看法。

        我自己沒有進行過ACM的訓練以及比賽。在這方面也比較欠缺,從本科到現在也是主要把時間放在做工程上邊來了。其實心裏邊很長時間以來還是竊以爲搞ACM的人挺厲害的。但是隨着時間的推移,慢慢的我有了一些自己的見解,也就是所謂的喫不

原创 決定在csdn開始寫自己的博客。

決定在csdn寫自己的博客。主要是技術的具體和抽象的總結,對生活和所謂的“道”的思考。 之前在百度空間零零碎碎的做了一些記錄~~ http://hi.baidu.com/cheetach_jiang

原创 測試CSDN的格式用。

int a=0; for(int i=0; i<100; i++){ a++; } 就像我寫程序喜歡自己寫個小demo測一測一樣,這裏弄一個文章,專門用來測試csdn博客各種格式的使用。 點贊 收藏 分

原创 LeetCode_Single Number II

Problem: Single Number II   Given an array of integers, every element appears three times except for one. Find

原创 6.5-9 merge k sorted lists into one sorted list with O(n lg k)

Give an O(n lg k)-time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements

原创 Redirect stdio in Java and C, 在Java和C代碼中重定向輸出。

Situation:     Printing to stdout is a major tool for debug at most time for most programmers, I believe. But sometimes

原创 9.2-3 Iterative version of Randomized-Select

9.2-3 Write an iterative version of RANDOMIZED-SELECT Analyse: For this the original recursive algorithm, the recursio

原创 TADM_3-11

Problem:      Suppose that we are given a sequence of n values x1, x2, ..., xn and seek to quickly answer repeated que

原创 原來C語言也有正則表達式的庫

這幾天開始在Hackerrank上邊刷題目玩。 做到正則表達式專題的時候,自己提交成功之後,可以看到別人提交的答案。 於是忍不住看了下一個人用C語言做的答案。好奇怎麼C語言也能使用正則表達式。 比較牛逼的是,C語言的正則表達式可以幫你找出

原创 TADM_3-15

Problem: Design a data structure that allows one to search, insert, and delete an integer X in O(1) time (i.e. , consta

原创 CJ_China_Campus_Test_Summary

This is my own summary of the contest, mainly to give myself advice on how to make me faster on the next contest. 1. Ba

原创 Leetcode_Populating Next Right Pointers in Each Node II

Question link: http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ Follow up for problem

原创 Longest Substring using dp and thinking on dp

Problem: find the longest consecutive substring of two string S, K. Use DP. Solution:     Matrix: m[m][n]         m[i]

原创 5.2-2 What is the probability that you hire exactly twice

Problem: In HIRE-ASSISTANT, assuming that the candidates are presented in a random order, what is the probability that