[C#][LeetCode][Easy] 344. Reverse String

心得:

非常單純的一題,把字串反轉過來就好了,一開始我的Code如下:

結果最後一個測試沒過顯示Time Out,我才發現我完全沒有考慮到校能問題…

就算用StringBuilder依然不會過…

拜大神才發現原來有Array.Reverse這個方法可以用,而且又好維護 !太神辣!

問題:

Write a function that takes a string as input and returns the string reversed.

答案:

  1. Array.Reverse
  2. LinQ

     

參考資料:

  1. Best way to reverse a string
  2. Property or indexer ‘string.this[int]’ cannot be assigned to — it’s read only


這裡的資訊對您有用嗎?歡迎斗內給我