注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 匿名 于 2022-7-2 18:03 编辑
2周前第一次Karat,第1题debug用太多时间以致于没时间做第2题,只好redo。
整个面试流程还是和第一次一样,1分钟自我介绍,接着10分钟是5选2,我选的System Internals and OOP:
System Internals:
- What is context switch? What cause will trigger ireturn the list of the coordinates of each letter that found.
- /*
- After catching your classroom students cheating before, you realize your students are getting craftier and hiding words in 2D grids of letters. The word may start anywhere in the grid, and consecutive letters can be either immediately below or immediately to the right of the previous letter.
- Given a grid and a word, write a function that returns the location of the word in the grid as a list of coordinates. If there are multiple matches, return any one.
- grid1 = [
- ['c', 'c', 't', 'n', 'a', 'x'],
- ['c', 'c', 'a', 't', 'n', 't'],
- ['a', 'c', 'n', 'n', 't', 't'],
- ['t', 'n', 'i', 'i', 'p', 'p'],
- ['a', 'o', 'o', 'o', 'a', 'a'],
- ['s', 'a', 'a', 'a', 'o', 'o'],
- ['k', 'a', 'i', 'o', 'k', 'i'],
- ]
- word1 = "catnip"
- word2 = "cccc"
- word3 = "s"
- word4 = "ant"
- word5 = "aoi"
- word6 = "ki"
- word7 = "aaoo"
- word8 = "ooo"
- grid2 = [['a']]
- word9 = "a"
- find_word_location(grid1, word1) => [ (1, 1), (1, 2), (1, 3), (2, 3), (3, 3), (3, 4) ]
- find_word_location(grid1, word2) =>
- [(0, 0), (1, 0), (1, 1), (2, 1)]
- OR [(0, 0), (0, 1), (1, 1), (2, 1)]
- find_word_location(grid1, word3) => [(5, 0)]
- find_word_location(grid1, word4) => [(0, 4), (1, 4), (2, 4)] OR [(0, 4), (1, 4), (1, 5)]
- find_word_location(grid1, word5) => [(4, 5), (5, 5), (6, 5)]
- find_word_location(grid1, word6) => [(6, 4), (6, 5)]
- find_word_location(grid1, word7) => [(5, 2), (5, 3), (5, 4), (5, 5)]
- find_word_location(grid1, word8) => [(4, 1), (4, 2), (4, 3)]
- find_word_location(grid2, word9) => [(0, 0)]
- Complexity analysis variables:
- r = number of rows
- c = number of columns
- w = length of the word
- */
复制代码 I came up a very close solution but unable to finish debugging before time ran out.
Hope this helps :)
|