leetcode
Java
hashmap
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows:
拉囉
cur_level
是目前第幾行,down
等於true時表示到了最下面那行並對cur_level
做反向加減result
裡並回傳雖然時間複雜度為,但如果用List就不用在額外使用map中的key,否則就會多出額外的運行時間
Runtime: 11 ms, faster than 37.57% of Java online submissions for ZigZag Conversion. Memory Usage: 39.8 MB, less than 39.96% of Java online submissions for ZigZag Conversion.