有些內容使用中英雙語,有些只有英文或中文。歡迎使用與分享任何內容,但先來信告知並標示此部落格為出處。
Some parts use both Chinese and English, but some parts use only one language. Feel free to share, but please contact me first and list this blog as your reference.

2014年6月1日 星期日

LeetCode OJ - Merge Intervals (C++) (try 9 times)

為了練習尋找實習時會碰到的問題,我用別人推薦的 LeetCode online judge。
希望能直接寫程式,不用事先編譯就能直接AC。
這是下面是我寫的 Merge Intervals 的解法。

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 Merge Intervals solution.

編譯錯誤次數 Compile Error number: 4
嘗試次數 Try number: 9 (RE: 5, WA: 3, AC: 1)
是否事先在其他工具編譯 if compile first in other tool: No

使用的程式語言 using programming language: C++
以前是否看過 seen this problem before: No

編譯錯誤原因:
1. 變數名稱打錯
2. 沒有在 compare function 加上 static
3. Structure type 名稱打錯

RE 原因:
1. 沒考慮 interval 是 empty input 的情況
2. compare function 裡面居然不能有條件式?

WA 原因:
1. 沒考慮相同 end 的 interval
2. 沒加上最後一個算好的 interval

點這裡看題目 Click here to see this Problem!

Please feel free to use it after adding this blog as an reference. (http://autekroy.blogspot.tw) If there is any mistake or comment, please let me know. :D 

歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )

沒有留言:

張貼留言

請留下您的任何想法或建議!
Please leave any thought or comment!