
簡介
本文是學習筆記,學習開源程式碼 OpenCV 中的實作,並且學習其中所使用的概念
Mat Implementation
struct Mat {
/*! includes several bit-fields:
- depth (4~-11)
- number of channels (1~3)
概念
交叉編譯 (Cross Compilation) 是指在一台電腦上編譯可以在另一種電腦上執行的程式
舉個例子: 你用 Windows 系統的電腦,寫了一個程式是給 Raspberry Pi (樹莓派,使用 ARM 架構) 跑的,在編譯時候正常來說編譯出的執行檔案只能在 Windows 上執行,如果要移植到樹梅派上就無法執行,因為編譯需要考量到編譯器以及對應的平台是什麼
確認目標平台
CPU 架構
ARM、x86
作業系統
Linux、Android、Windows
交叉編譯器
Question link
Link
Intuition
Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory.
給定字串s,將其翻轉
最直接想法就是直接使用新的一個字串,並從尾到頭歷遍字串,但是需要O(n)的空間,因此如果使用雙指標法的話就不需要這麼多空間,直接交換頭尾兩個指標的字元就好
Approach
Question link
Link
Intuition
Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.
給定一個整路n,以迴旋方式產生一個陣列,並將數字從1填充到n2
題目要求以迴旋方式將數字填入到矩陣中,因此我們需要考慮每一個邊,該如何設計迴圈的操作條件,依舊是要堅持迴圈不變量的原則,填充的順序為
上列為由左到右
右列為由上至下