## Unable to install Homebrew

Unable to install Homebrew with this? ruby -e “\$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)” What’s happened -e:70: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 ==> This script will install: /usr/local/bin/brew /usr/local/Library/… /usr/local/share/man/man1/brew.1 Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew Password: ==> Downloading and installing Homebrew… remote: Counting objects:…

Read more...

## Interview Practice 28 – Counting One in Binary Expression

Question Given a number, find the number of 1 in the number’s binary expression. For example, binary express of 10 is 1010. So the number of 1 in it is 2. Solution To solve this, we can check each bit by shifting the bits one by one. 1. 1010 -> check 0 2. 101 -> check…

Read more...

## Interview Practice 17 – Find The String Appeared Once

Question Given a string, write an algorithm to find the character inside that appeared only once. For example, the result for string “abaccdeff” is b. Solution We can use a hashtable to count the appearance times for each character. Then rescan the hashtable for the character that appeared only once. These two step take O(n)…

Read more...

## Interview Practice 13 – Last Kth Node of Linked List

Question Given a linked list, find the Kth last node in a linked list. The last 0th node is the tail node in the linked list. Solution Easy task. Construct 2 pointers: P1 and P2. First, both of them are set to head. Move P2 to the next Kth node. Example # node structure class…

Read more...

## Interview Practice 12 – Sum from 1 to N Unconventionally

Question Sum up 1 to n without using division, multiplication, for loop, while loop, if else, switch and condition statement (A?B:C). Solution 1 Actually, for loop can be simulated through making use of the static property. Since static value will be stored in the class, we can increase the value every time we init a…

Read more...

## Interview Practice 06 – Appearance Count of Numbers

Question 腾讯面试题： 给你10分钟时间，根据上排给出十个数，在其下排填出对应的十个数 要求下排每个数都是先前上排那十个数在下排出现的次数。 上排的十个数如下： 【0，1，2，3，4，5，6，7，8，9】 Solution 初看此题，貌似很难，10分钟过去了，可能有的人，题目都还没看懂。 举一个例子， 数值: 0,1,2,3,4,5,6,7,8,9 分配: 6,2,1,0,0,0,1,0,0,0 0在下排出现了6次，1在下排出现了2次， 2在下排出现了1次，3在下排出现了0次…. 以此类推.. Sample Code [expand title=”Sample Code in C++” tag=”h4″] //数值: 0,1,2,3,4,5,6,7,8,9 //分配: 6,2,1,0,0,0,1,0,0,0 #include <iostream> using namespace std; #define len 10 class NumberTB { private: int top[len]; int bottom[len]; bool success; public: NumberTB(); int* getBottom(); void setNextBottom(); int getFrequecy(int num);…

Read more...

## My Portifilio

Actually, this website was my portfolio webpage before becoming a wordpress. It is moved to here: nicholasworkshop.com/portfolio. Using wordpress, I put the old webpage aside and always forgot to transfer the information from it to the front page. Anyway, I hope this can remind me of the projects and webpages I created.

Read more...

## Finally, the blog moved back to nicholasworkshop.com!

Today, I moved my nicholasworkshop.wordpress.com to my owned domain nicholasworkshop.com, integrated with my old portfolio website. Thanks to my subscribers, my blog has been having a steady viewing rate over time. However, all those traffics went to wordpress.com as the blog was hosted there. To redirect them back to my domain, I have been preparing the things…

Read more...

## InstaMusic Got 10,000 Downloads over Lunar New Year!

Happy lunar new year to all. I am flattered. In less than a month since I put the InstaMusic to the Android Market on 27 Dec 2011, today it has already more than 10,000 downloads. To be honest, I never expected this. If you are uninitialized, InstaMusic is a music player android application with simple and stylish…

Read more...