Weekly Contest
限制 :
2 <= s.length <= 100
s consists only of lowercase English letters.
利用前後夾擊的方式算出最長的序列,有點類似 LCS ,但又不太像。
程式碼:
限制 :
1 <= k <= 105
計算 k 的平方根 sqrt_num。如果 k 是完全平方數,最小操作數為 sqrt_num + sqrt_num - 2。如果 k 接近完全平方數,則為 sqrt_num + sqrt_num - 1。其他情況下,操作數量為 sqrt_num + sqrt_num。
程式碼:
限制 :
1 <= nums.length == freq.length <= 105
1 <= nums[i] <= 105
-105 <= freq[i] <= 105
freq[i] != 0
The input is generated such that the occurrences of an ID will not be negative in any step.
程式碼:
限制 :
104
程式碼: