filmov
tv
Leetcode 3110 - Score of a String [1/6/24]

Показать описание
Time Taken: ~5 mins
Tag: LeetCode Easy
High-level ideas:
- Maintain variables:
- prev: ascii value of previous character
- curr: ascii value of current character
- diff: absolute difference in value between prev and curr
- ans: keeps track of the ans to be returned
- Iterate through string, for each iteration, add diff to ans.
Tag: LeetCode Easy
High-level ideas:
- Maintain variables:
- prev: ascii value of previous character
- curr: ascii value of current character
- diff: absolute difference in value between prev and curr
- ans: keeps track of the ans to be returned
- Iterate through string, for each iteration, add diff to ans.