作者devilkool (全糖可可粉)
標題Re: [閒聊] 每日leetcode
時間2024-06-01 15:04:36
※ 引述《DJYOSHITAKA (franchouchouISBEST)》之銘言:
: 3110. Score of a String
唉我只有easy能秒解了
又想那個了
C#:
public int ScoreOfString(string s)
{
var score = 0;
for (int i=1;i<s.Length;i++)
{
var x = s[i-1] - '0';
var y = s[i] - '0';
score += Math.Abs(y - x)
}
return score;
}
--
※ 發信站: 批踢踢實業坊(ptt-club.com.tw), 來自: 114.136.224.3 (臺灣)
※ 文章網址: https://ptt-club.com.tw/Marginalman/M.1717225479.A.6A0
推 SecondRun: 大師 06/01 15:06
推 wu10200512: 大師 06/01 15:09
推 sustainer123: 大師 06/01 15:17
推 deatheo: 大師 06/01 15:36