2014年5月24日 星期六

LeetCode OJ - Single Number (C++) (try 1 time)

為了練習尋找實習時會碰到的問題,我用別人推薦的 LeetCode online judge。
希望能直接寫程式,不用事先編譯就能直接AC。
這是下面是我寫的  Single Number 的解法。
這篇是舊版本,請看這個改良後的版本

To practice future interview question, I use LeetCode online judge.
I am trying to type code directly on website without compile in other tool.
The following program is my Single Number solution.
This article is a improved version. See the improved version here.

2014年5月21日 星期三

Study Abroad 留學之路 - 基礎知識、名詞介紹

持續更新中(5/21, 2014)

下面有一些背景知識、基本名詞介紹,希望看完後你能更能了解留學申請。

延伸閱讀: 留學之路 - 我要準備留學! overview
延伸閱讀: 我的背景與申請結果

2014年5月20日 星期二

UVa OJ - 題目記錄 Problem records (2014年 一月-四月, January-April)

簡單記錄一下我過的UVa OJ 題目和我認為的困難度,照月份分開
請點進來看我之前所AC的題目與程式!

This article simply record my Accepted UVa OJ problems and the difficulty I thought. Please click "Read more" to see my previous AC problems and programs.

等待中的一顆星:10141, 10209, 10300


2014年 四, 五, 六月 - 2014 April, May, June
AC problemsAC DateDifficultyClue / Hint
441 Lotto4/02, 2014★★DFS
572 Oil Deposits4/06, 2014★★DFS
10924 Prime Words5/29, 2014Prime

2014年5月18日 星期日

Design Patterns 筆記 - Singleton Pattern 單例模式

初學Design Pattern,如有謬誤或超級大錯還請指教。

如不知道什麼是 Design Patterns,可先閱覽一下這篇:Design Patterns 筆記 - Overview

想知道其他種 Design Patterns,請看這篇:Design Patterns 筆記 - Categories 分類條列

另外,如果不懂Java的介面,可以參考這一篇:JAVA - 什麼是介面?


以下內容主要從 tutorialspoint 的 Design Patterns - Singleton  Pattern 翻譯而來。
故事背景跟額外補充是參考自王者歸來:品味Java的21種設計模式

故事背景:

很多專案或是系統,都有一些開發人員定義的設定檔或資料檔,該如何讀取這些檔案內容?
好像不難啊? 直接寫一個 class ,能讀取檔案,能回傳設定檔的內容即可。
用戶在使用時直接建立此物件即可使用。

這會有問題嗎? 有!
如果系統之中有多處需要用到同一個設定檔呢? 那是不是會new()非常多個設定檔物件!
嚴重浪費系統空間資源,如果設定檔內容較大,那不是死定了嗎 = =?

所以其實我們只需要一個設定檔物件即可,Singleton Pattern 就是解決方案!