面試過程:
Interviewer:Hello, I am your interviewer, now I have a question for you, please provide your solution.
In a database context, the need to find two data records whose specific attributes sum up to a target value is often required for querying and data analysis purposes. This involves searching for two records in a dataset where the sum of particular attributes matches a predefined target value. Such queries and analyses are commonly performed in various database-driven applications, allowing users to extract meaningful insights or perform specific operations based on data criteria.
Interviewee: OK i think this is a two sum ploblem.
I need to two for loop .
the first for loop : from i to length number
the second for loop:from i+1 to length number
if number i + number j == target
return i,j
Interviewer: OK! How to reduce execution time?
Interviewee: i think i need to use dictionary to store number and index. and one for loop to iterate through each element in the list of integers nums.
now i start to coding.
面試官: 你好,從我手上這份簡歷,我感受到您對程式設計的熱情和專業,但在我們談及工作內容前我想幫公司同仁先認識你在程式開發的想法和風格」
接下來我想問妳幾個問題:字串是對稱的,即從左到右和從右到左閱讀都是相同的。例如,"radar" 和 "deified" 都具有這個特殊性質。字串是由相同的字符組成,但字符的順序可以不同。例如,"abb" 和 "bab" 都具有這個特殊性質。
面試者: 先將他轉換為字串 接著用一個result儲存
如果他們一樣 他就是回文
面試官: 有沒有辦法在沒有使用字串的情況完成
面試者: 可以 因為X是整數 所以只要將他一直除10 就能將它倒放回來
面試官: OK 那你有辦法在數字有正負號時將他反轉嗎?
面試者: 先將整數轉換為字串 若轉換後最後一個字為'-' 則將他加入到字串最前面
再將字串轉為整數判斷有沒有超過範圍 即可獲得答案