---
# System prepended metadata

title: 2024 / 08/ 07 mock interview

---

// 2024/08/07
//interviewer: Alisha
//interviewee: Ted

// LC 2115: https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/

//----------------------------------

//題目1講解:
//time: 11:10

ingredient : [["b", "c"]]
recepies : ["a"]
2
input: ["a"] [["b", "c"]]
b+c -> a

{strawberry, water} → strawberry juice = 1
{strawberry juice, sugar} → strawberry jam = 2
{strawberry jam, strawberry, cake, cream, chocolate} → strawberry cake
{powder, sugar, egg} → cake
{milk, egg} → cream

level: {strawberry:0, water :0 , strawberry juice:1, }

int x = dfs(cake)



strawberry cake 最複雜，ans is 3
(-> strawberry jam -> strawberry juice -> strawberry/water)

// 1. ----------------------------------
//time: 11:16
//作法講解:
unoreder_map: key: str, value: str

strawberry cake -> 3
strawberry jam -> 2
strawberry juice -> 1
water, strawberry -> 0
  
dfs strawberry cake max(2, 0, 1 0, 0) + 1

// code: 11:23 (11:28) - 12:00
```cpp=
int def findMaxElment(vector<vector<str>>& ingredient, vector<str>& recepies) {
  unordered_map<str, vector<str>> recepe_table;
  for (int i = 0; i < recepies.size(); i++) {
    recepe_table[recepies[i]] = ingredient[i];
  }
    
  unordered_map<str, int> level;
  
  function<void<int>> dfs = [&](str recepe) {
    // check if recorded 
    queue<str> ingred;
    for (str& re: recepe_table[recepe]) {
      ingred.push_back(re);
    }
    int recepe_level = 0;
    
    while (!ingred.empty()) {
        str s = ingred.front();
        ingred.pop();
        
        if (level.find(s) != level.end()) {
            recepe_level = max(recepe_level, level[s]);
        } else {
            
        }
    }
  }
  
  int ans = 0;
  for (str& recepe: recepies) {
    ans = max(ans, dfs(recepe));
  }
  return ans;
}
```

//----------------------------------

//作法講解:
//time: 

//----------------------------------

//作法講解:
//time: 

// =======
// feed back

- circle? 
- empty, intput type --> ✅

- 求助、思考時要說一下、安靜不知道卡在哪、掉線or not
- auto&
- 註解、邊打邊講

- top down dfs + record -> top down dp
- bottom up dp -> topology

//  =======
  
// finish
  
  
  
  
  
  
  
  
  
  
  
  
  
  


