看板 Soft_Job 關於我們 聯絡資訊
※ 引述《pandaforme (建 建)》之銘言: : PO這篇文章的本意是想討論 公司出了靈活的面試題目來測試面試者 : 但是面試方法竟然如此的封閉 身為被面試者應該如何應對 : 假設某一家公司拿指考的數學題目來考面試者 : 面試者分別有 : 1. 普通的一般人 (大學以上的學歷) : 2. 準備要參加指考的應屆考生 : 3. 對數學非常有天分的神人 : 考試時間為一小時 考完後 單純依據分數來判定有沒有入取 : 一般人在有限時間且缺乏練習的情況下 考得贏第2和第3類的人嗎? : 之前遇到幾個公司面試就是這樣的做法... : 考完就考券收一收 也沒有問你怎麼解 請等待回應 : 就算有問 面試官心中都有一定的成見 : 真的是自己能力不足 被問到釘在白板上也認了... : 可是能這樣的機會也沒有 : 公司的面試方式似乎卻在走回頭路 只看你的筆試成績 : 卻一點都不在意你對問題的解決方式和想法 : 既然有版友想看題目 那我就PO出來吧 : http://tinyurl.com/3srmqfc 並且請考慮當N很大的時候 : 請在半小時內想出解法並且使用你拿手的程式語言實作它 : 我是第一次看到這個題目 : 當下判斷我不可能在半小時內想出最佳解且要考慮當N很大的時候 : 所以就採用硬幹法一一去算每個元素出現的次數 : 想好並且寫完CODE半小時也差不多過了 : 面試官就收回考券 說:等我們的技術長看過後再決定是否有第二次面試 : 想當然結果就是謝謝 再連絡... : 嗯 : 這樣的陣亡方式 感覺有點死的不明不白 : 似乎這樣的面試方式 在浪費彼此的時間... : 換個角度想 只能有緣再見面了~ 寫了一下剛才看到時推文所說最直觀硬幹的方法 (謎: hashmap 是給你這樣用的嗎?) (廢: 記憶體吃很大 吃不用錢) package test; import java.util.HashMap; import java.util.Map; public class DomiTest { public static void main (String args[]) { int length = 40, theDomi = -9999,// 不給初值 compiler 不給過才給 index = (int)(Math.random()*(length/2)); // 想拿第幾個索引 int[] theArray = new int[length]; boolean notFound = true; Map countMap = new HashMap(), indexMap = new HashMap(); // 稍微作弊, 容易產生出有 domi 的陣列 for (int i = 0;i < length;i ++) { if (i < (length/3)) theArray[i] = (int)(Math.random()*3); else theArray[i] = (int)(Math.random()*2); } // 開始找, go go go int cnt; int val; System.out.println(" start, the full array is "); for (int i = 0;i < length;i ++) { val = theArray[i]; System.out.print(val + ", "); if (countMap.containsKey(val)) cnt = (Integer)countMap.get(val)+1; else cnt = 1; countMap.put(val, cnt); // index 是指想取第幾個的索引, i 才是真正的索引 if (cnt == index) indexMap.put(val, i); if (cnt >= (length/2+1) && notFound) { notFound = false; theDomi = val; } } // 找完了, 以下印結果 System.out.print("\n\n"); System.out.println(" has domi? " + !notFound); System.out.println("count of 0 = " + countMap.get(0)); System.out.println("count of 1 = " + countMap.get(1)); System.out.println("count of 2 = " + countMap.get(2)); System.out.println(" domi value= " + (notFound? "not found" : theDomi)); System.out.println(" the count of the domi= " + (notFound? "not found" : countMap.get(theDomi))); System.out.println(" the random number is " + index); System.out.println(" the random index of the domi= " + (notFound? -1 : indexMap.get(theDomi)) + " (first is 0, -1 denotes not found)"); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.216.1.59 ※ 編輯: lovdkkkk 來自: 61.216.1.59 (08/02 00:23)