# 2023 年「[資訊科技產業專案設計](https://hackmd.io/@sysprog/info2023)」作業 1
> 貢獻者:天兵-TianBing
> [模擬面試影片(漢)](https://youtu.be/XjD2g7JtPkQ)
> [模擬面試影片(英)](https://youtu.be/JeqPg_DiaDo)
## [1. Two sum](https://leetcode.com/problems/two-sum/description/)
面試過程:
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
```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
for j in range(i+1 , len(nums)):
if(nums[i] + nums[j]) == target:
return [i,j]
return []
```
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.
```python
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
num_dict = {}
for i in range(len(nums)):
num1 = nums[i]
num2 = target - num1
if num2 in num_dict:
return [num_dict[num2], i]
num_dict[num1] = i
```
## [9.Palindrome](https://leetcode.com/problems/palindrome-number/description/)
面試官: 你好,從我手上這份簡歷,我感受到您對程式設計的熱情和專業,但在我們談及工作內容前我想幫公司同仁先認識你在程式開發的想法和風格」
接下來我想問妳幾個問題:字串是對稱的,即從左到右和從右到左閱讀都是相同的。例如,"radar" 和 "deified" 都具有這個特殊性質。字串是由相同的字符組成,但字符的順序可以不同。例如,"abb" 和 "bab" 都具有這個特殊性質。
面試者: 先將他轉換為字串 接著用一個result儲存
如果他們一樣 他就是回文
面試官: 有沒有辦法在沒有使用字串的情況完成
面試者: 可以 因為X是整數 所以只要將他一直除10 就能將它倒放回來
```python
class Solution:
def isPalindrome(self, x: int) -> bool:
num = 0
a = x
while(a > 0):
temp = a % 10
num = num * 10 + temp
a = int(a / 10)
if x == num and x >= 0:
return True
else:
return False
```
## [7. reverse integer](https://leetcode.com/problems/reverse-integer/description/)
面試官: OK 那你有辦法在數字有正負號時將他反轉嗎?
面試者: 先將整數轉換為字串 若轉換後最後一個字為'-' 則將他加入到字串最前面
再將字串轉為整數判斷有沒有超過範圍 即可獲得答案
```python
class Solution:
def reverse(self, x: int) -> int:
s = str(x)
s = s[::-1]
if s[-1] == '-':
s = '-' + s[:-1]
ans = int(s)
if ans > 2**31-1 or ans < -2**31:
return 0
return ans
```
## 初步檢討
* 一開始講想法的時候要表達更明確一點
* 語句要通順
* 英文發音有很大進步空間
* 使用每個方式應該要更清楚解釋給interviewer了解為什麼
* 沒有做好 REACTO
## 改善方法
* 對程式需要更加理解才能在當下表達的順暢
* 多練習英文口說與聽力
* 多看幾次影片將REACTO的流程學起來
---
## 作業二-他評01
### 針對interviewer
- [ ] 優點
* "你好,從我手上這份簡歷,我感受到您對程式設計的熱情和專業,但在我們談及工作內容前我想幫公司同仁先認識你在程式開發的想法和風格"這段是很棒的開頭。
* 語速正常。
- [ ] 可改進之處:
* [0:31](https://youtu.be/XjD2g7JtPkQ?si=tWQfi_1Ce9vmBCjG&t=31): 這裡題目解釋也點不清楚,不應該說"我要你寫一個程式具有由右到左以及由左到右相同的特性",應該說"我要你寫一個程式能判斷字串是否由右到左唸和由左到右唸都相同"
* 題目稍微包裝一下會更好。
* [0:02](https://youtu.be/JeqPg_DiaDo?si=XAjCIdfrf5xUeyhT&t=2): 不要說自己是面試官。
* [0:25](https://youtu.be/JeqPg_DiaDo?si=f5O1wD09_iq5OOt1&t=25): 注意purpose發音。
* [0:52](https://youtu.be/JeqPg_DiaDo?si=r39kqNG1CHzXJh5G&t=52): 突然亂笑有失專業性。
### 針對interviewee
- [ ] 優點:
* 語速正常
- [ ] 可改進之處
* 缺乏Repeat
* 缺乏TEST的步驟
* 缺乏example的動作
* 如果能邊打code邊解釋會更好
* 沒有時間複雜度或空間複雜度的探討
- [ ] 整體可改進之處
* 講話節奏有點奇怪,可以調整一下呼吸。
### TWO SUM C++ Code
```cpp
#暴力解
vector<int> twoSum(vector<int>& nums, int target) {
vector<int> ans;
for(int i = 0; i< nums.size(); i++){
for(int j = 0; j< nums.size(); j++){
if(i == j){break;}
if (target == nums[i] + nums[j]){
ans.push_back(i);
ans.push_back(j);
return ans;
}
}
}
return ans;
}
#HASH
vector<int> twoSum(vector<int>& nums, int target) {
unordered_map<int, int> num_dict;
for (int i = 0; i < nums.size(); i++) {
int num1 = nums[i];
int num2 = target - num1;
if (num_dict.find(num2) != num_dict.end()) {
return {num_dict[num2], i};
}
num_dict[num1] = i;
}
return {};
}
```
## 作業二-他評02
### Interviewer
* 在介紹題目的時候也許可以有一些圖文可能會讓interviewee更能理解題目。
### Interviewee:
* 寫程式碼的同時可以試著同時解說,不然可能過程會有點乾。
* 缺乏reacto的一些步驟。
- [ ] 整體可改進之處:
* 英文口說可能需要再加強,讓整體更加的流暢。
* 有時候會有一些不必要的肢體動作,需盡量避免。
* 說話可以再更有自信。
## 作業二-他評03
### Interviewer
- [ ] 優點
* 態度親切、活潑,能降低interviewee的緊張和減少彼此之間的距離。
### Interviewee
- [ ] 優點
* 對於自己的程式碼有信心。
- [ ] 可改進之處
* [1:01](https://youtu.be/XjD2g7JtPkQ?t=56): 這邊可以邊說明邊打下大綱,例如打下 result=反過來的字串
* 缺少 REACTO 的 TEST,前面先列舉一些例子後,可以在 [2:22](https://youtu.be/XjD2g7JtPkQ?t=142) 這邊將例子代回去測試看看。
* [3:40](https://youtu.be/XjD2g7JtPkQ?t=218): 回答可行性後,應先說明怎麼做,例如:我會將input的整數透過迴圈抓最後一個數字,並對該數字做/=10,讓數字可以迭代...之類的,而非直接動手做,做的過程也缺乏說明。
## 作業四-他評04
### Interviewer
- [ ] 優點
* 對話過程舒適不會給面試者很有壓力的感覺。
- [ ] 可改進之處
* [0:45](https://youtu.be/XjD2g7JtPkQ?t=45):身體建議不要一直莫名晃來晃去的。
* 提問改用情境題會比較好
* [0:20](https://youtu.be/JeqPg_DiaDo?t=20): 就算是看稿念題目,也不要太明顯是看著搞念,感覺對面試官來說不太專業。
### Interviewee
- [ ] 可改進之處
* [1:35](https://youtu.be/XjD2g7JtPkQ?t=95):很突然的開始寫code,也沒有邊寫邊講解,會讓人不知道你現在在幹嘛。
* [4:50](https://youtu.be/XjD2g7JtPkQ?t=290): 面試時手機應該關靜音。
* [6:41](https://youtu.be/XjD2g7JtPkQ?t=401): 講話可以自信一點。
* [4:34](https://youtu.be/JeqPg_DiaDo?t=274): NG片段,這是忘記剪掉嗎?