LeetCode Practice 55.
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.
Given a list of
stones' positions (in units) in sorted ascending order, determine if the frog can cross the river by landing on the last stone. Initially, the frog is on the first stone and assumes the first jump must be
If the frog’s last jump was
k units, its next jump must…
std::thread and resource deadlock
terminate called after throwing an instance of 'std::system_error' what(): Resource deadlock avoided
Two reasons cause this error.
I utilized the boost io_service to run a heartbeat routine in another thread. It skipped some details in the following code, but you’re still able to see a heartbeat_routine task that would bring a new one.
Apparently, the heartbeat_routine function takes a weak pointer as arguments. It brought us to the error condition (1. The thread owner joins itself.) when it’s out of the main function which meant…
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.
MediaTek Interview Questions
Okay 上一篇才剛發沒有多久, 趁著還稍微記得題目內容來記錄一下, 希望可以幫到迷途的孩子們
筆試14題(C/C++), 包含填充題跟選擇與填充題 & 兩題上機考, 共50分鐘
螢幕會提示時間, 並建議分配26分鐘在選擇與填充題, 24分鐘在上機考
由於時間緊迫, 非常難以記住全部14題, 此部分僅回憶出題目想考的概念, 實際數字並不相同, 請同學們當成練習題即可
keyword: (1) global variable (2) pointers as function arguments
keyword: (1) global variable
keyword: (1) Macro
MediaTek interview sharing
由此可知, 其實我過去經歷對於面試軟韌體職缺沒太大加分, 所以應徵的時間點真的非常重要呢 (有人內推的確會讓面試機會變多!)
整個面試中的技術問答沒有我想像中的多, 可能是我把氣氛帶往比較輕鬆的方向才變成這樣, 但總而言之還是完成了一個關卡
二面完一級長官之後, 收到了聯發科的無情無聲卡, 人生好難。
Day of the Programmer, Python implementation
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. …
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.
You may assume that word1 does not equal to word2, and word1 and word2 are both in the list.
Assume that words = [“practice”, “makes”, “perfect”, “coding”, “makes”].
Input:word1 = 「coding」, word2 = 「practice」Output:3
Input:word1 = “makes”, word2 = “coding”Output:1
此方法需要traversal整個array來建立hash table, 之後再去比較其value中的最小距離
給予兩個array, 內容為兩個input值出現在words中的index值, 需要traversal整個array來建立此兩個array, 之後再去比較其value中的最小距離, Time complxity與 Thought1 差不多
設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)…
Tell you how to use the same code to run in Python 2 and 3.
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.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!
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
pyzeal-1.1.0-cp27-cp27mu-linux_x86_64.whl is not a supported wheel on this platform.
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', 'none', 'any'), ('py26'…
From Taiwan, a beautiful island. Learning English and sharing code experience.