Sometimes we need t to trace the execution order to make sure the program runs as our expectations, especially the multi-thread programs. We all know ctime is a great function to help us get the current time. It can convert current time to string. But it seems insufficient if you’re handling millisecond cases.

Here we can leverage boost library to acquire subtle time.

Reference:


MediaTek Interview Questions

Okay 上一篇才剛發沒有多久, 趁著還稍微記得題目內容來記錄一下, 希望可以幫到迷途的孩子們

C語言測試

筆試14題(C/C++), 包含填充題跟選擇與填充題 & 兩題上機考, 共50分鐘

螢幕會提示時間, 並建議分配26分鐘在選擇與填充題, 24分鐘在上機考

由於時間緊迫, 非常難以記住全部14題, 此部分僅回憶出題目想考的概念, 實際數字並不相同, 請同學們當成練習題即可

選擇與填充題

  • Question 1

keyword: (1) global variable (2) pointers as function arguments

  • Question 2

keyword: (1) global variable

  • Question 3

keyword: (1) Macro

  • Question …

MediaTek interview sharing

原本呢, 從去年8月就已經請朋友幫忙投遞履歷

但直到上個禮拜才發來面試通知… (我都到職三個月了呢

想了想, 機會難得

決定前往聖地朝聖!

Background

  • 工作經驗: 兩年
  • 擅長程式語言: 專精Python, 略懂C/C++
  • 工作領域: Back-end system developement
  • 學歷: 洗的四大碩 lol

由此可知, 其實我過去經歷對於面試軟韌體職缺沒太大加分, 所以應徵的時間點真的非常重要呢 (有人內推的確會讓面試機會變多!)

Before the interview

  1. 去官網填寫個人基本資料, 很重要, 這是面試官在面試前了解你的唯一管道
  2. 備妥個人資料(Resume, 學碩成績單, 作品集…)
  3. 準備相關的筆試(後續再來發一篇筆試考題好了)
  4. 個人有準備面試用的簡報(大概除了碩論以來我準備過最漂亮的一份PowerPoint), 如有準備的同學請提早通知人資單位並請他們準備有投影機的房間

The interview

看來三月不是應徵旺季, 似乎面試者並沒想像中的多(不然也不會找我面試lol)

面試流程如下

  1. 筆試14題(C/C++), 包含填充題跟選擇題 & 兩題上機考, 共50分鐘
    C語言考蠻多東西, 例如 function pointer, static, global, volitile, macro, C++ template
  2. 個人自我介紹(使用精美ppt做簡報), 在過程中盡量把你自己負責過的專案做個簡單扼要的說明, 尤其是你負責的部分, 這很能提起面試官的興趣
    這邊我有跟面試官討論一下平行化該怎麼做比較好, 他給了我一個沒想過的答案
  3. 面試官提問攻擊, 你負責接下攻擊並反擊, 可能包含了你剛剛報告的內容, 資料結構, 作業系統, 計算機概論… etc.
    我個人被問到 dead lock, synchonization, critical section
  4. 白 板 題 ! ! ! 面試官看我有記錄一些LeetCode題目在github上, 他就挑了兩題 (1) Are two trees equal (2) Reverse LinkedList
    (面試官: 我知道你比較熟Python, 但現在你當然要用C寫)
  5. 面試官說明工作內容 & 你的提問時間

End

整個面試中的技術問答沒有我想像中的多, 可能是我把氣氛帶往比較輕鬆的方向才變成這樣, 但總而言之還是完成了一個關卡

如果有幫助的話請按讚讚~

補充:

下篇 — 聯發科 C語言測試題目


Day of the Programmer, Python implementation

Questions

Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the 256th day of the year) during a year in the inclusive range from 1700 to 2700.

From 1700 to 1917, Russia’s official calendar was the Julian calendar; since 1919 they used the Gregorian calendar system. The transition from the Julian to Gregorian calendar system occurred in 1918, when the next day after January 31st was February 14th. …


Hacker rank — Two characters


LeetCode Record

LeetCode

Question 1: 243 Shortest Word Distance I

Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

Note:

You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.

Example:

Assume that words = [“practice”, “makes”, “perfect”, “coding”, “makes”].

Input:word1 = 「coding」, word2 = 「practice」Output:3

Input:word1 = “makes”, word2 = “coding”Output:1

Thought 1 — Hash table by my intuition

此方法需要traversal整個array來建立hash table, 之後再去比較其value中的最小距離

Thought 2 — Two array

給予兩個array, 內容為兩個input值出現在words中的index值, 需要traversal整個array來建立此兩個array, 之後再去比較其value中的最小距離, Time complxity與 Thought1 差不多

Thought 3 — Two points

設index1, index2 = -1, -1 , traversal整個array 若word1出現且index2為-1則word1紀錄index1=i; 若word2出現且index1為-1則記錄index2=i; 若index1 != -1 且 index2 != -1 則找最短距離與目前最優解做比較 取最小值

def getShortest(self, word1, word2): i1…

Tell you how to use the same code to run in Python 2 and 3.

Background

After packing my module to wheel, I started to test it and found that the code below couldn’t run in Python 3 but it’s fine in Python 2.

from modulename import *

This is the folder structure

modulename
├── __init__.py
└── modulename.so

modulename.so is the file providing functionalities and I needed to wrap some class names as another. The __init__.py is like this:

from modulename import *
ClsPublic = ClsPersonal # export it as ClsPublic

Then the import error came out. So frustrating!

Solution

The fact…


A Bug

Background

I tried to install a wheel package file by pip, but it showed the error.

$ pip install dist/mypkg-1.1.0-cp27-cp27mu-linux_x86_64.whl

I got:

pyzeal-1.1.0-cp27-cp27mu-linux_x86_64.whl is not a supported wheel on this platform.

Solution

Renaming the wheel file to fit the supported wheel format. To get the supported format in your environment.

Python 2.7.11 (default, May 8 2019, 02:10:04) [GCC 5.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pip; print(pip.pep425tags.get_supported()) [('cp27', 'cp27m', 'manylinux1_x86_64'), ('cp27', 'cp27m', 'linux_x86_64'), ('cp27', 'none', 'manylinux1_x86_64'), ('cp27', 'none', 'linux_x86_64'), ('py2', 'none', 'manylinux1_x86_64'), ('py2', 'none', 'linux_x86_64'), ('cp27', 'none', 'any'), ('cp2', 'none', 'any'), ('py27', 'none', 'any'), ('py2'…

I got started to use protobuf in Python , after installed google.protobuf compiler.

$ yum install protobuf-compiler

Problem

Traceback (most recent call last):
File "test_proto.py", line 1, in <module>
import test_simple_service_pb2
File "/app/build_py3/test_simple_service_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'

Solution

If you’re using pip3.

$ pip3 install protobuf

Pip2

$ pip install protobuf

Pybind11 is a very powerful library that is able to program between Python and C++.

Yesterday I wanted to use C++ abstract class in Python, read and tried the code on the official document.

But it ran into a weird error at PYBIND11_OVERRIDE_PURE when compiling.

"pybibd11" error: expected primary-expression before ',' token

Can’t find any solutions from the official doc.

Solution

Replacing PYBIND11_OVERRIDE_PURE with PYBIND11_OVERLOAD_PURE can get over the compiling.

Jaime Lin

From Taiwan, a beautiful island. Learning English and sharing code experience.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store