sysprog
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: info2022-homework1 --- # 2022 年「[資訊科技產業專案設計](https://hackmd.io/@sysprog/info2022)」作業 1 > 貢獻者: 旗忠一仁-someone > 🧔: interviewer > 👶: interviewee > [模擬面試錄影(漢)](https://youtu.be/9wEl1LJ8-Uk) > [模擬面試錄影(英)](https://youtu.be/-mvhE_K7FBg) ## [141. Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/) / [142. Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/) 1. Practice speaking for long recording session 1. Rehearsal before recording, try to do the interview in one take 1. Wrong intonation for majority of the video 1. Not speaking clearly 1. [11:11](https://youtu.be/u8BifwrZlac?t=671) for byte addressable memory, assume at least 32-bit architecture, hence `>> 4` instead of `>> 2` 1. [19:55](https://youtu.be/u8BifwrZlac) Mistakes in code `line 72` should be `head != fast` `line 73 - 74` isn't assigning value to `head` and `fast` Code (Linked List Cycle - failed in leetcode) : ```c bool hasCycle(struct ListNode *head) { struct ListNode *dummy = malloc(sizeof(struct ListNode)); while (head && head->next) { if (head->next == dummy) { return true; } struct ListNode *prev = head; head = head->next; prev->next = dummy; } return false; } ``` Code (Linked List Cycle) : ```c bool hasCycle(struct ListNode *head) { struct ListNode *tmp = malloc(sizeof(struct ListNode)); while (head && head->next) { if (head->next == tmp) { return true; } struct ListNode *prev = head; head = head->next; prev->next = tmp; } return false; } ``` Code (Linked List Cycle II) : ```c struct ListNode *detectCycle(struct ListNode *head) { uintptr_t addr[400000] = {0}; while (head) { if (addr[(uintptr_t)head%400000]) return head; addr[(uintptr_t)head%400000] = 1; head = head->next; } return NULL; } ``` Code (Linked List Cycle II) : ```c struct ListNode *detectCycle(struct ListNode *head) { struct ListNode *slow, *fast; slow = fast = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == fast) { while (head != fast) { head = head->next; fast = fast->next; } return head } } return NULL; } ``` --- ## [64. Add Binary](https://leetcode.com/problems/add-binary/) > 模擬面試錄影 (漢) 1. Talk faster 1. [14:37](https://youtu.be/rlCHl8ae_3I?t=878) Give alternative for more efficient division / modulo before introducing bitwise addition Both division and modulo operates on a constant, optimize by multiplication by inverse Code (Add Binary) ```c #define C2D(x) ((x) - '0') #define D2C(x) ((x) + '0') char * addBinary(char * a, char * b) { int la = strlen(a), lb = strlen(b); int l = (la < lb ? lb : la) + 2; char *res = malloc(l); for (int i = 0; i < l - 1; ++i) res[i] = '0'; res[--l] = '\0'; char c = 0; while (l--) { char b1 = 0, b2 = 0; if (la) b1 = C2D(a[--la]); if (lb) b2 = C2D(b[--lb]); char xor = b1 ^ b2; res[l] = D2C(c ^ xor); c = (c & xor) | (b1 & b2); } return res + (res[0] == '0'); } ``` ## Problem [8. String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) question not well-defined (does not fully define what should be 0 and what should be a value) whack-a-mole after the base code is written down (ignore edge case in interview) how to deal with overflow (after adding value vs before adding value) [1935. Maximum Number of Words You Can Type](https://leetcode.com/problems/maximum-number-of-words-you-can-type/) Approach 1. Brute Force Approach 2. Hash Map [1508. Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/) Solution : Brute Force (+ qsort) Followup : What if initially sorted (binary search) --- ## Attempts ### Attempt 1 > Recording [718. Maximum Length of Repeated Subarray](https://leetcode.com/problems/maximum-length-of-repeated-subarray/) 1. Use text to explain approaches 1. Time are wasted explaining pointless code, elaborate better or type faster [1:01](https://youtu.be/Bm1UXzt7_ng?t=61) function prototype [2:50](https://youtu.be/Bm1UXzt7_ng?t=170) nested for loops 1. Bugs in code [3:03](https://youtu.be/Bm1UXzt7_ng) `n1` -> `n2` [5:49](https://youtu.be/Bm1UXzt7_ng) `arr[k]` -> `arr1[k]`, `arr[l]` -> `arr2[l]` [12:01](https://youtu.be/Bm1UXzt7_ng?t=721) `len` -> `len[][]` 1. Become more familiar with programming terms in Chinese 1. Wrong example / explanation [7:24](https://youtu.be/Bm1UXzt7_ng?t=445) Operation reduced is not from multiple non-consecutive subarrays, the correct way explanation of code is : `[1,2,3,4,5]` after `1` is evaluated, as `[1,2,3,4]` is the common subarray, when evaluating `2`, the result from `1` will be carry over. 1. Disable vim error bell 1. Question / Example could be explained better 1. Hesitate less when speaking, stop dragging words when speaking ### Attempt 2 (no interviewer) > Recording [237. Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list/) 1. Find something for interviewer 1. Description not in sync with actions 1. Missed opportunity to slip in additional information Delete - Remove different use case How remove without returning reference causes memory leaks How to deal with memory leaks (Address Sanitizer, Garbage Collector, etc.) 1. [8:32](https://youtu.be/R8dUgL1bRa8?t=512) Elaborate on problems when modifying values of nodes What will happen when a function do a sneaky change that is not apparent from the name 1. Larger Font # 同儕檢討 ### ****64. Add Binary**** - 可以在每段程式碼前加註解,像27-29行為初始化,可以加註 - 當下沒有解釋C2D實作 - [9:08](https://youtu.be/9wEl1LJ8-Uk?t=548) 解釋要怎麼解決頭是0的情況有點不清楚,重複聽才懂,寫法有點不直觀的感覺 - [9:57](https://youtu.be/9wEl1LJ8-Uk?t=597) 感覺一開始有點沒回答到interviewer的問題,我在聽的時候就一直在等interviewee解釋他的C2D,但沒有很快地給出答案 - [11:30](https://youtu.be/9wEl1LJ8-Uk?t=691) 這段時間滑鼠一直動跟一直移動輸入的地方,會躁起來 - [11:30](https://youtu.be/9wEl1LJ8-Uk?t=691) 迴圈的解釋我覺得沒解釋到甚麼,有點不知道在說甚麼的感覺,可以舉個例子更好 - [12:34](https://youtu.be/9wEl1LJ8-Uk?t=754) 解釋ASCII code我覺得不需要,主考官應該都會知道這些東西 - [13:00](https://youtu.be/9wEl1LJ8-Uk?t=812) 為了給更多解法結果自己卡了,有點太多 - [14:20](https://youtu.be/9wEl1LJ8-Uk?t=859) interviwer說會因為%跟/影響效率,我覺得有點誇張,我沒遇過改進效率是要把除法跟取餘數改成Binary的形式,轉問題的方式我覺得太硬,聽起來很怪,並且interviewee就突然打開畫圖軟件來解釋全加器,有點怪 - code會讓人有背答案的感覺 - 其實整體來說我覺得蠻棒的,說話速度不會太快,打code很舒服 ### ****141. Linked List Cycle**** - 講話聲音被鍵盤聲蓋掉很多,加上有口音,沒辦法很好好地聽interviewee說甚麼 - 覺得一開始提出的修改Node的方法可以不用講,因為用這種方法就有點像是你自己修改題目,而不是去想解決方法

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully