question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
⌀
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
flatten-a-multilevel-doubly-linked-list
JAVA 1ms DFS Self Explainatory Easy
java-1ms-dfs-self-explainatory-easy-by-b-ykvg
\nclass Solution {\n public Node flatten(Node head) {\n if(head == null) return null;\n Node ptr = head;\n while(ptr.next != null) ptr =
bharat194
NORMAL
2022-03-16T08:53:26.696739+00:00
2022-03-16T08:54:31.040276+00:00
129
false
```\nclass Solution {\n public Node flatten(Node head) {\n if(head == null) return null;\n Node ptr = head;\n while(ptr.next != null) ptr = ptr.next;\n Node p = head;\n while(p != null){\n if(p.child != null){\n Node chi = p.child;\n Node nx...
3
0
['Java']
0
flatten-a-multilevel-doubly-linked-list
Python solution, Easy Understanding without using stack
python-solution-easy-understanding-witho-g4e9
\nclass Solution:\n def flatten(self, head: \'Optional[Node]\') -> \'Optional[Node]\':\n if head is None:\n return\n c = head\n
Nish786
NORMAL
2022-02-08T06:58:19.596067+00:00
2022-02-11T05:41:24.542104+00:00
163
false
```\nclass Solution:\n def flatten(self, head: \'Optional[Node]\') -> \'Optional[Node]\':\n if head is None:\n return\n c = head\n while c:\n if c.child is not None:\n ch = c.child\n ch.prev = c\n t = c.next\n c.ne...
3
0
['Linked List', 'Python']
0
score-of-a-string
One line Solution 😱😱
one-line-solution-by-hi-malik-h75m
It\'s a pretty simple problem! You just take a character and subtract the next character. If we convert them into integers, they get converted into their ASCII
hi-malik
NORMAL
2024-06-01T00:23:57.018068+00:00
2024-06-01T00:38:39.764572+00:00
19,311
false
It\'s a pretty simple problem! You just take a character and subtract the next character. If we convert them into integers, they get converted into their ASCII values. So, if we subtract two characters, they are actually subtracted based on their ASCII values!\n\nTherefore, it\'s quite simple: you just subtract two adj...
44
3
['C', 'Python', 'Java']
15
score-of-a-string
💯Faster✅💯Less Mem✅Detailed Explaination🎯Linear Iter🧠Step-by-Step Explaination✅Python🐍Java🍵
fasterless-memdetailed-explainationlinea-2p98
\uD83D\uDE80 Hi, I\'m Mohammed Raziullah Ansari, and I\'m excited to share solution to this question with detailed explanation:\n\n# \uD83C\uDFAFProblem Explain
Mohammed_Raziullah_Ansari
NORMAL
2024-06-01T02:38:06.639960+00:00
2024-06-01T02:51:32.656030+00:00
6,591
false
# \uD83D\uDE80 Hi, I\'m [Mohammed Raziullah Ansari](https://leetcode.com/Mohammed_Raziullah_Ansari/), and I\'m excited to share solution to this question with detailed explanation:\n\n# \uD83C\uDFAFProblem Explaination: \nThe problem is to compute the score of a given string `s`. The score is calculated based on the ab...
32
1
['String', 'C++', 'Java', 'Python3']
5
score-of-a-string
Easy string vs adjacent_difference+accumulate vs 1-line recursion||0ms beats 100%
easy-string-vs-adjacent_differenceaccumu-epwl
Intuition\n Describe your first thoughts on how to solve this problem. \nVery easy question!\n\nFor exercise, use C++ STL to make the 2nd approach; adjacent_dif
anwendeng
NORMAL
2024-06-01T00:04:34.381879+00:00
2024-06-01T09:34:02.000430+00:00
7,553
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nVery easy question!\n\nFor exercise, use C++ STL to make the 2nd approach; adjacent_difference, accumulate with lambda function\n\n3rd approach is 1-line recursion.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse...
31
0
['String', 'Recursion', 'C', 'Python', 'C++']
9
score-of-a-string
⬆️🔥 Beats 100% | Space O(1) | Time O(n) | Python3 | Easy ✅
beats-100-space-o1-time-on-python3-easy-gm3ud
Submission\n\n\n\n# Intuition\n\nThe question is to calculate the sum of the absolute difference between every two consecutive elements\' ASCII value, so you ne
adityasony967
NORMAL
2024-04-15T18:11:13.847332+00:00
2024-04-15T18:11:13.847356+00:00
2,297
false
# Submission\n\n![leetcodesos.png](https://assets.leetcode.com/users/images/1684f7f6-72f9-49c6-8971-4dd27de55b6c_1713202493.683806.png)\n\n# Intuition\n\nThe question is to calculate the sum of the absolute difference between every two consecutive elements\' `ASCII` value, so you need to iterate through strings using t...
21
1
['String', 'Python3']
2
score-of-a-string
✅ EASY WITH EXPLANATION || 💯 % on runtime 🚀
easy-with-explanation-on-runtime-by-iamh-mo8t
Intuition \uD83C\uDF1F\n\nWhen given a string, one natural way to measure how "different" consecutive characters are is to look at their ASCII values. By calcul
IamHazra
NORMAL
2024-06-01T06:16:54.219642+00:00
2024-06-01T15:01:43.955251+00:00
3,321
false
# Intuition \uD83C\uDF1F\n\nWhen given a string, one natural way to measure how "different" consecutive characters are is to look at their ASCII values. By calculating the absolute difference between the ASCII values of consecutive characters in the string, we can get a measure of how "different" the string is at each ...
13
0
['String', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
5
score-of-a-string
✅Detailed Explanation💯Beginner Friendly🔥Simple and Easy🔥Strings🔥
detailed-explanationbeginner-friendlysup-xbqv
Submission Link: Python-96.79%,Java-99.87%,C++ - 100%🎯 Problem ExplanationWe are given a stringsand we need to calculate the score of this string.The score is
Saketh3011
NORMAL
2024-06-01T00:32:52.912031+00:00
2025-02-22T14:21:54.158228+00:00
1,524
false
![image.png](https://assets.leetcode.com/users/images/e7b40a76-3e72-4f0c-b211-35635179e9a9_1717201599.0780618.png) ![image.png](https://assets.leetcode.com/users/images/b75f6bc9-637d-468b-b750-1dcf95c141db_1717200908.8531256.png) **Submission Link:** [Python-96.79%](https://leetcode.com/problems/score-of-a-string/subm...
12
1
['String', 'Iterator', 'C++', 'Java', 'Python3', 'Rust', 'Ruby', 'Kotlin', 'JavaScript', 'C#']
6
score-of-a-string
[Java / Python 3] Time O(n) space O(1) codes
java-python-3-time-on-space-o1-codes-by-nvgi4
\njava\n public int scoreOfString(String s) {\n int score = 0;\n for (int i = 1; i < s.length(); ++i) {\n score += Math.abs(s.charAt
rock
NORMAL
2024-04-13T16:05:55.068601+00:00
2024-04-13T16:05:55.068631+00:00
693
false
\n```java\n public int scoreOfString(String s) {\n int score = 0;\n for (int i = 1; i < s.length(); ++i) {\n score += Math.abs(s.charAt(i) - s.charAt(i - 1));\n }\n return score;\n }\n```\n```python\n def scoreOfString(self, s: str) -> int:\n return sum(abs(ord(x) ...
12
0
[]
3
score-of-a-string
Simple java solution
simple-java-solution-by-siddhant_1602-jwcv
Complexity\n- Time complexity: O(n) \n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n public int scoreOfString(String s) {\n int val=0;\n
Siddhant_1602
NORMAL
2024-04-13T16:03:13.441936+00:00
2024-04-13T16:03:13.441969+00:00
1,243
false
# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n public int scoreOfString(String s) {\n int val=0;\n for(int i=0;i<s.length()-1;i++)\n {\n char c=s.charAt(i);\n char d=s.charAt(i+1);\n val=val+Math.abs(...
11
0
['Java']
2
score-of-a-string
💯✅🔥Easy Java ,Python3 and C++ Solution|| 1 ms ||≧◠‿◠≦✌
easy-java-python3-and-c-solution-1-ms-_-e0f0e
Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind this approach is that the score of a string is directly proportion
suyalneeraj09
NORMAL
2024-06-01T00:30:15.252748+00:00
2024-06-01T00:30:15.252777+00:00
1,882
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind this approach is that the score of a string is directly proportional to the sum of the absolute differences between adjacent characters. By iterating through the string and calculating the absolute difference between ...
10
0
['String', 'C++', 'Java', 'Python3']
9
score-of-a-string
[Rust] true one-liner
rust-true-one-liner-by-tmtappr-rv0u
Approach\nA windowing iterator over the byte array representing the string is created. A map iterator producing the absolute difference of each adjacent pair of
tmtappr
NORMAL
2024-06-01T02:25:02.319900+00:00
2024-06-01T02:39:53.732203+00:00
203
false
# Approach\nA windowing iterator over the byte array representing the string is created. A map iterator producing the absolute difference of each adjacent pair of bytes is created, then `.sum()` is invoked on it to produce the sum of differences.\n\nThis is an actual "one-liner". I see a lot of solutions (to other prob...
9
0
['Rust']
0
score-of-a-string
Python 3 || 2 lines, pairwise || T/S: 99% / 93%
python-3-2-lines-pairwise-ts-99-93-by-sp-t4h0
\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n\n absdiff = lambda x: abs(ord(x[0]) - ord(x[1]))\n\n return sum(map(absdiff,pairw
Spaulding_
NORMAL
2024-04-13T16:23:37.201165+00:00
2024-06-12T05:43:07.384448+00:00
782
false
```\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n\n absdiff = lambda x: abs(ord(x[0]) - ord(x[1]))\n\n return sum(map(absdiff,pairwise(s)))\n```\n[https://leetcode.com/problems/score-of-a-string/submissions/1231356748/](https://leetcode.com/problems/score-of-a-string/submissions/12313567...
9
0
['Python3']
0
score-of-a-string
Best approach solution (for gen alpha fr fr)
best-approach-solution-for-gen-alpha-fr-bjhcc
Intuitionbeginner friendly (especially gen alpha)ApproachbraincellComplexity Time complexity: O(1) Space complexity: O(your brain) Code
eQfHNpKjdl
NORMAL
2025-04-01T08:06:50.243704+00:00
2025-04-01T08:06:50.243704+00:00
143
false
# Intuition beginner friendly (especially gen alpha) # Approach braincell # Complexity - Time complexity: O(1) - Space complexity: O(your brain) # Code ```cpp [] typedef int skibidi; typedef string rizz; using edging = vector<skibidi>; using muhahaha = vector<edging>; istream& gooning = cin; ostream& ohio = cout; #...
8
0
['C++']
5
score-of-a-string
Simple Java solution
simple-java-solution-by-ydvaaman-8fj1
\nclass Solution {\n public int scoreOfString(String s) {\n int sum = 0;\n for (int i = 0; i < s.length() - 1; i++) {\n sum += Math.
ydvaaman
NORMAL
2024-04-13T16:01:08.937757+00:00
2024-04-13T16:01:08.937779+00:00
937
false
```\nclass Solution {\n public int scoreOfString(String s) {\n int sum = 0;\n for (int i = 0; i < s.length() - 1; i++) {\n sum += Math.abs((s.charAt(i) - \'0\') - (s.charAt(i + 1) - \'0\'));\n }\n return sum;\n }\n}\n```
8
1
['Java']
3
score-of-a-string
C++ beats 100%
c-beats-100-by-deleted_user-c1n4
C++ beats 100%\n\n\n\n# Code\n\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int sum = 0;\n for(int i = 0; i+1 <= s.size()-1;i++
deleted_user
NORMAL
2024-06-01T05:16:33.674513+00:00
2024-06-01T05:16:33.674545+00:00
63
false
C++ beats 100%\n![image.png](https://assets.leetcode.com/users/images/0daf048f-f835-401c-b702-934aea9153a2_1717218990.0708005.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int sum = 0;\n for(int i = 0; i+1 <= s.size()-1;i++){\n int a = s[i];\n ...
7
0
['C++']
0
score-of-a-string
Python | Easy
python-easy-by-khosiyat-1o5d
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n score = 0\n for i in range(1,
Khosiyat
NORMAL
2024-06-01T05:36:58.199483+00:00
2024-06-01T05:36:58.199514+00:00
318
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/score-of-a-string/submissions/1273862859/?source=submission-ac)\n\n# Code\n```\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n score = 0\n for i in range(1, len(s)):\n score += abs(ord(s[i]) - ord(s[i - 1])...
6
0
['Python3']
0
score-of-a-string
Java beats 100%
java-beats-100-by-deleted_user-43b5
Java beats 100%\n\n\n\n# Code\n\nclass Solution {\n public int scoreOfString(String s) {\n return iterateString(0,s); \n }\n\n public static i
deleted_user
NORMAL
2024-06-01T05:18:24.692644+00:00
2024-06-01T05:18:24.692681+00:00
47
false
Java beats 100%\n![image.png](https://assets.leetcode.com/users/images/0253c27c-ff43-46f6-b53a-d8c0fce70b6a_1717219094.0910015.png)\n\n\n# Code\n```\nclass Solution {\n public int scoreOfString(String s) {\n return iterateString(0,s); \n }\n\n public static int iterateString(int n, String s){\n ...
6
0
['Java']
0
score-of-a-string
✅EASY AND SIMPLE SOLUTION✅(Beats 100.00% of users with C++)
easy-and-simple-solutionbeats-10000-of-u-yevb
\n\n# Code\n\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int score = 0;\n \n\n for(int i=0; i<s.size()-1; i++){\n
deleted_user
NORMAL
2024-06-01T03:53:52.497135+00:00
2024-06-01T04:00:55.388058+00:00
334
false
\n\n# Code\n```\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int score = 0;\n \n\n for(int i=0; i<s.size()-1; i++){\n if(int(s[i]) > int(s[i+1])){\n score = score + int(s[i]) - int(s[i+1]);\n } else {\n score = score + int(s[i+1...
6
0
['C++']
1
score-of-a-string
100% Beats || Simple CPP Solution || Anyone Will Understand
100-beats-simple-cpp-solution-anyone-wil-rocr
Intuition\nThe problem asks for finding the score of a string based on the absolute difference between consecutive characters in the string.\n\n# Approach\nTo s
Its_Shojib
NORMAL
2024-06-01T02:40:31.651816+00:00
2024-06-01T02:40:31.651834+00:00
2,573
false
# Intuition\nThe problem asks for finding the score of a string based on the absolute difference between consecutive characters in the string.\n\n# Approach\nTo solve this problem, we can iterate through the string and calculate the absolute difference between each character and its consecutive character. We\'ll accumu...
6
1
['C++']
4
score-of-a-string
📌 Easy Solution with Python / C / C++
easy-solution-with-python-c-c-by-umutert-gbp8
Intuition 🤔The goal is to calculate a “score” for the given string s, which is the sum of the absolute differences between the ASCII values of consecutive chara
umutertugrul
NORMAL
2025-01-19T11:18:52.800282+00:00
2025-01-19T11:18:52.800282+00:00
738
false
# Intuition 🤔 The goal is to calculate a “score” for the given string s, which is the sum of the absolute differences between the ASCII values of consecutive characters in the string. The task involves comparing adjacent characters, converting them to their ASCII values, and summing up the differences. # Approach 💡 ...
5
0
['C', 'C++', 'Python3']
0
score-of-a-string
💯JAVA Solution Explained in HINDI
java-solution-explained-in-hindi-by-the_-5064
https://youtu.be/7cH7OZhUJrE\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote
The_elite
NORMAL
2024-06-01T05:01:19.725562+00:00
2024-06-01T05:01:19.725590+00:00
1,694
false
https://youtu.be/7cH7OZhUJrE\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\n# Subscribe:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\nSubscribe Goal:- 500\nCurrent Subscriber:...
5
0
['Java']
0
score-of-a-string
Easy C++ Solution | Linear Time | Constant Space | Beats 100 💯✅
easy-c-solution-linear-time-constant-spa-tl27
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to compute a score for a given string s, which is defined as the sum of the
shobhitkushwaha1406
NORMAL
2024-06-01T03:20:35.353660+00:00
2024-06-01T03:20:35.353685+00:00
283
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to compute a score for a given string `s`, which is defined as the sum of the absolute differences between the ASCII values of consecutive characters in the string.\n\n# Approach\n<!-- Describe your approach to solving the pro...
5
0
['String', 'C++']
2
score-of-a-string
simple and easy understand solution
simple-and-easy-understand-solution-by-s-keb6
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n\nclass Solution {\npublic:\n int scoreOfString(string s) \n {\n int res = 0, n = s
shishirRsiam
NORMAL
2024-04-13T18:26:13.456442+00:00
2024-04-13T18:26:13.456465+00:00
702
false
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution {\npublic:\n int scoreOfString(string s) \n {\n int res = 0, n = s.size();\n for(int i=0;i<n-1;i++)\n res += abs((s[i]-\'a\') - (s[i+1]-\'a\')); \n return res;\n }\n};\n```
5
0
['String', 'C', 'C++', 'Java', 'C#']
6
score-of-a-string
Yes, It's that easy 🤗🤗
yes-its-that-easy-by-utkarshpriyadarshi5-qwa6
Welcome, I hope you like this Solution \uD83E\uDD17\uD83E\uDD17\n# Approach\n1. Character Differences:\n\n - Imagine each letter as having a number associate
utkarshpriyadarshi5026
NORMAL
2024-06-01T10:47:44.822405+00:00
2024-06-01T10:47:44.822437+00:00
707
false
# Welcome, I hope you like this Solution \uD83E\uDD17\uD83E\uDD17\n# Approach\n1. `Character Differences:`\n\n - Imagine each letter as having a number associated with it (its position in the alphabet). \'a\' is 1, \'b\' is 2, and so on. \n - The code looks at each pair of neighboring letters and finds the differ...
4
0
['String', 'Java', 'Go', 'Python3']
0
score-of-a-string
0ms - Beats 100% ✅🔥🔥🔥| Python, C++💻 | SUPER EASY Approach, Explanation📕
0ms-beats-100-python-c-super-easy-approa-5ibl
0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | SUPER EASY Approach, Explanation\uD83D\uDCD5\n\n## 1. Proof\n Describe yo
kcp_1410
NORMAL
2024-06-01T07:07:45.522202+00:00
2024-06-01T07:07:45.522228+00:00
183
false
# 0ms - Beats 100% \u2705\uD83D\uDD25\uD83D\uDD25\uD83D\uDD25| Python, C++\uD83D\uDCBB | SUPER EASY Approach, Explanation\uD83D\uDCD5\n\n## 1. Proof\n<!-- Describe your first thoughts on how to solve this problem. -->\n### 1.1. C++\n![image.png](https://assets.leetcode.com/users/images/f311fef7-e34a-4115-a27d-3e7f31d27...
4
0
['String', 'Python', 'C++', 'Python3']
0
score-of-a-string
simple solution with explanation
simple-solution-with-explanation-by-anup-12gr
Intuition\n- substract adjacent characters and add this absolute value in res\n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n
anupsingh556
NORMAL
2024-06-01T04:17:04.954250+00:00
2024-06-01T04:17:04.954288+00:00
203
false
# Intuition\n- substract adjacent characters and add this absolute value in res\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: Constatnt Space\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n in...
4
0
['C++']
2
score-of-a-string
✅Python🔥Easy Solution🔥 Pairwise Function🔥
pythoneasy-solution-pairwise-function-by-54us
Code\n\nclass Solution:\n def pairwise(self, iterable):\n a, b = tee(iterable)\n next(b, None)\n return zip(a, b)\n \n def scoreOf
KG-Profile
NORMAL
2024-06-01T02:09:44.085371+00:00
2024-06-01T02:09:44.085422+00:00
121
false
# Code\n```\nclass Solution:\n def pairwise(self, iterable):\n a, b = tee(iterable)\n next(b, None)\n return zip(a, b)\n \n def scoreOfString(self, s: str) -> int:\n absdiff = lambda x: abs(ord(x[0]) - ord(x[1]))\n return sum(map(absdiff, self.pairwise(s)))\n```
4
0
['Python3']
0
score-of-a-string
JAVA Easy Solution [ 99.91% ]
java-easy-solution-9991-by-rajarshimitra-uebl
Approach\n- Initialize a variable sum to keep track of the score.\n- If the input string s is empty, return 0.\n- If the length of s is 1, return the ASCII valu
RajarshiMitra
NORMAL
2024-05-10T06:12:41.862292+00:00
2024-06-16T07:04:54.374448+00:00
15
false
# Approach\n- Initialize a variable `sum` to keep track of the score.\n- If the input string `s` is empty, return 0.\n- If the length of `s` is 1, return the ASCII value of the only character.\n- Iterate over the characters of the string starting from the second character (index 1).\n- Calculate the absolute difference...
4
0
['Java']
0
score-of-a-string
0ms | 100% beat | Simple and Easy Approach
0ms-100-beat-simple-and-easy-approach-by-i6hi
Approach\nLoop through the array and calculate difference of character at index i and i+1, loop goes all the way upto size-1, store it in varaible res and at ea
ahlyab
NORMAL
2024-04-14T09:29:05.722779+00:00
2024-04-14T09:29:05.722805+00:00
166
false
# Approach\nLoop through the array and calculate difference of character at index `i` and `i+1`, loop goes all the way upto `size-1`, store it in varaible `res` and at each iteration add the difference after taking it\'s `abs` to `res `\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n#...
4
0
['C++']
0
score-of-a-string
🔥✅💯Easiest C++ / Python3 🐍 / Java / C / Python ✅🔥☠️ Beats 💯 ✅
easiest-c-python3-java-c-python-beats-by-vd4y
Intuition\n\n\n\n\n\nC++ []\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int score = 0;\n for(int i = 1; i < s.length(); ++i)\n
Edwards310
NORMAL
2024-04-13T16:05:36.103205+00:00
2024-04-13T16:16:27.577630+00:00
305
false
# Intuition\n![0ehh83fsnh811.jpg](https://assets.leetcode.com/users/images/21b27e86-0e54-41f3-b132-ed9a82560d00_1713024254.6682923.jpeg)\n![Screenshot 2024-04-13 213305.png](https://assets.leetcode.com/users/images/e6b7fc99-52dc-4d36-a4e5-48ffe6c32bf4_1713024261.095585.png)\n![Screenshot 2024-04-13 213312.png](https://...
4
0
['C', 'Python', 'C++', 'Java', 'Python3']
2
score-of-a-string
Score of a String | 0ms and 100.00% beats
score-of-a-string-0ms-and-10000-beats-by-vkfd
IntuitionThe problem requires us to compute the score of a string by summing the absolute differences between adjacent character ASCII values. We can solve this
hariharan-dev-05
NORMAL
2025-03-16T16:23:46.260256+00:00
2025-03-16T16:23:46.260256+00:00
240
false
# Intuition The problem requires us to compute the score of a string by summing the absolute differences between adjacent character ASCII values. We can solve this efficiently by iterating through the string once. # Approach 1. Convert each character in the string to its ASCII value using `ord()`. 2. Use `zip()` to pa...
3
0
['Python3']
0
score-of-a-string
One Linear - Clean Code
one-linear-clean-code-by-bazil_zywotow-m6u8
null
Bazil_Zywotow
NORMAL
2025-01-18T11:17:19.691289+00:00
2025-01-18T11:17:19.691289+00:00
234
false
```javascript [] const scoreOfString = (s, [first, ...tail] = [...s].map(c => c.charCodeAt(0))) => tail.reduce(([score, prev], v) => [score + Math.abs(prev - v), v], [0, first])[0]; ```
3
0
['JavaScript']
1
score-of-a-string
100% Beats
100-beats-by-kumarrishikant660-p4mi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
kumarrishikant660
NORMAL
2024-12-03T05:10:12.687549+00:00
2024-12-03T05:10:12.687585+00:00
225
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O...
3
0
['C++']
3
score-of-a-string
100% Go
100-go-by-kaya-sem-vece
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n\n# Complexity\n- Tim
Kaya-Sem
NORMAL
2024-08-06T13:22:07.343527+00:00
2024-08-06T13:25:46.380502+00:00
114
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n\n# Complexity\n- Time complexity: $\\Theta(N)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: $\\Theta(N)$\n<!-- Add your space com...
3
0
['Go']
1
score-of-a-string
Kotlin one line solution using zipWithNext
kotlin-one-line-solution-using-zipwithne-4kp8
Intuition\nThe goal is to compute the "score" of a string, defined as the sum of absolute differences between the ASCII values of adjacent characters. This can
shtanko
NORMAL
2024-06-01T20:10:59.819306+00:00
2024-06-01T20:10:59.819341+00:00
164
false
# Intuition\nThe goal is to compute the "score" of a string, defined as the sum of absolute differences between the ASCII values of adjacent characters. This can be visualized as finding the "distance" between each consecutive character and summing these distances.\n\n# Approach\n - Iterate through the string and for e...
3
0
['Kotlin']
0
score-of-a-string
[Python, Java] Elegant & Short | 1-Line | Pairwise
python-java-elegant-short-1-line-pairwis-zs6c
Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n# Code\npython []\nclass Solution:\n def scoreOfString(self, string: str) -> int:\n r
Kyrylo-Ktl
NORMAL
2024-06-01T16:36:45.875736+00:00
2024-06-01T16:40:31.087640+00:00
364
false
# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(1)$$\n\n# Code\n```python []\nclass Solution:\n def scoreOfString(self, string: str) -> int:\n return sum(abs(ord(a) - ord(b)) for a, b in pairwise(string))\n```\n```java []\npublic class Solution {\n public int scoreOfString(String string)...
3
0
['Python', 'Python3']
0
score-of-a-string
O(n) Straight forward solution ✅
on-straight-forward-solution-by-yousufmu-b123
Intuition\n Describe your first thoughts on how to solve this problem. \n- We can simply traverse through the array and find absoulte difference ASCII between t
yousufmunna143
NORMAL
2024-06-01T13:37:12.715412+00:00
2024-06-01T13:37:12.715454+00:00
1,424
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- We can simply traverse through the array and find absoulte difference ASCII between two adjacent characters and return the sum of these differences.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Declare a var...
3
0
['String', 'Java']
1
score-of-a-string
100% better solution||Easy||C++
100-better-solutioneasyc-by-singhpayal22-lt73
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
payalsingh2212
NORMAL
2024-06-01T11:52:11.677486+00:00
2024-06-01T11:52:11.677512+00:00
291
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $...
3
0
['C++']
2
score-of-a-string
Java Easy to Understand Solution with Explanation || 100% beats
java-easy-to-understand-solution-with-ex-t4gk
Intuition\n> Iterate through the string and remember the last ASCII value.\n\n# Approach\n\n\n\n1. Initialization:\n - int ans = 0;: This initializes the var
leo_messi10
NORMAL
2024-06-01T11:40:17.913770+00:00
2024-06-01T11:40:17.913833+00:00
43
false
# Intuition\n> Iterate through the string and remember the last ASCII value.\n\n# Approach\n\n\n\n1. **Initialization**:\n - `int ans = 0;`: This initializes the variable `ans` to 0, which will hold the final score.\n - `int size = s.length();`: This stores the length of the input string `s`.\n - `int last = s...
3
0
['String', 'Java']
1
score-of-a-string
NO BRAINING AT ALL
no-braining-at-all-by-nurliaidin-2gdn
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Nurliaidin
NORMAL
2024-06-01T10:41:34.358996+00:00
2024-06-01T10:41:34.359020+00:00
234
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O...
3
0
['String', 'C++', 'JavaScript']
0
score-of-a-string
Scala: fold by indices
scala-fold-by-indices-by-serhiyshaman-rv7m
Code\n\nobject Solution {\n def scoreOfString(s: String): Int = \n (1 until s.length).foldLeft(0)((sum, i) => sum + (s(i - 1) - s(i)).abs)\n}\n
SerhiyShaman
NORMAL
2024-06-01T06:12:25.976975+00:00
2024-06-01T06:12:25.977003+00:00
40
false
# Code\n```\nobject Solution {\n def scoreOfString(s: String): Int = \n (1 until s.length).foldLeft(0)((sum, i) => sum + (s(i - 1) - s(i)).abs)\n}\n```
3
0
['Scala']
0
score-of-a-string
Easy C++ Solution
easy-c-solution-by-atharav_s-uwng
Video Explanation\nhttps://youtu.be/PgW73G4Um8I?si=E311v3I4mf52lNE9\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe task is to c
Atharav_s
NORMAL
2024-06-01T04:25:49.386840+00:00
2024-06-01T04:25:49.386869+00:00
1,434
false
# Video Explanation\nhttps://youtu.be/PgW73G4Um8I?si=E311v3I4mf52lNE9\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe task is to compute the "score" of a given string based on the absolute differences between the ASCII values of consecutive characters. The idea is to measure how d...
3
0
['C++']
0
score-of-a-string
JAVA || EASYY || WITH EXPLANATION || BEATS 99.87% 🔥
java-easyy-with-explanation-beats-9987-b-emi3
Intuition\nWe can iterate over each character using for loop. Calculate absolute differnce between each adjacent character and add it to sum.\n\n# Approach\n1)
avnisinngh
NORMAL
2024-06-01T01:19:49.735220+00:00
2024-06-01T01:19:49.735240+00:00
164
false
# Intuition\nWe can iterate over each character using for loop. Calculate absolute differnce between each adjacent character and add it to sum.\n\n# Approach\n1) Create Variables `sum` to store the total sum , `first`to store the value of first element and `scnd` to store the value of second element.\n2) For loop start...
3
0
['Java']
0
score-of-a-string
JavaScript Solution | Simple
javascript-solution-simple-by-pranav_rao-a5z0
Approach\n Describe your approach to solving the problem. \nWe Iterate over each letter of the string and find its ASCII character using the charCodeAt function
pranav_rao_97
NORMAL
2024-05-06T16:17:45.978678+00:00
2024-05-06T16:17:45.978709+00:00
239
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nWe Iterate over each letter of the string and find its ASCII character using the `charCodeAt` function.\nWe then subtract `s[i + 1]` from `s[i]` and then get its absolute value using `Math.abs()`.\nWe then add this value to `sum` and store the result ...
3
0
['JavaScript']
1
score-of-a-string
✅✅Beats 100% | Beginner Friendly 💯
beats-100-beginner-friendly-by-viresh_de-da1q
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. \n\n -->\n\n\n\n\n\n\n\n\n\n\n# Code\npython []\nclass Solution:\n def scoreOf
viresh_dev
NORMAL
2024-04-13T16:15:29.458079+00:00
2024-04-13T16:15:29.458103+00:00
602
false
<!-- # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach --> -->\n\n<!-- Describe your approach to solving the problem. -->\n\n<!-- # Complexity -->\n<!-- - Time complexity: -->\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n<!-- - Space complexity: -->\n<!-- A...
3
0
['Python3']
1
score-of-a-string
🔥Beats 100% - Brute Force | Clean Code | C++ |
beats-100-brute-force-clean-code-c-by-an-p4g9
Code\n\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int res = 0;\n for (int i = 1; i < s.size(); i++)\n {\n r
Antim_Sankalp
NORMAL
2024-04-13T16:07:45.416468+00:00
2024-04-13T16:07:45.416498+00:00
552
false
# Code\n```\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int res = 0;\n for (int i = 1; i < s.size(); i++)\n {\n res += abs(s[i] - s[i - 1]);\n }\n\n return res;\n }\n};\n```
3
0
['C++']
0
score-of-a-string
Easiest Java Solution
easiest-java-solution-by-1asthakhushi1-b3wv
\n\n# Code\n\nclass Solution {\n public int scoreOfString(String s) {\n int sum=0;\n for(int i=1;i<s.length();i++)\n sum+=Math.abs((
1asthakhushi1
NORMAL
2024-04-13T16:06:25.701887+00:00
2024-04-13T16:07:29.753237+00:00
251
false
\n\n# Code\n```\nclass Solution {\n public int scoreOfString(String s) {\n int sum=0;\n for(int i=1;i<s.length();i++)\n sum+=Math.abs((int)s.charAt(i)-(int)s.charAt(i-1));\n return sum;\n }\n}\n```
3
0
['Java']
3
score-of-a-string
Score of a String
score-of-a-string-by-bear001-tqa8
IntuitionThe problem requires calculating the sum of the absolute differences between the ASCII values of adjacent characters in a given string. Since the absol
BEAR001
NORMAL
2025-03-29T18:13:32.369715+00:00
2025-03-29T18:13:32.369715+00:00
64
false
# **Intuition** The problem requires calculating the sum of the absolute differences between the ASCII values of adjacent characters in a given string. Since the absolute difference measures how far apart two values are, we can efficiently solve this by iterating through the string and summing up these differences. --...
2
0
['String', 'Python3']
0
score-of-a-string
Easy java solution.. Beats 99%
easy-java-solution-beats-99-by-krishn13-hs5v
IntuitionThe problem requires calculating the total difference between consecutive characters in a string. My first thought was to iterate through the string an
krishn13
NORMAL
2025-03-14T13:10:01.070548+00:00
2025-03-14T13:10:01.070548+00:00
228
false
# Intuition The problem requires calculating the total difference between consecutive characters in a string. My first thought was to iterate through the string and compute the absolute difference between adjacent characters. # Approach 1. Initialize a variable `sum` to store the total score. 2. Iterate throu...
2
0
['Java']
0
score-of-a-string
Beats 100% ✅C++ Easy to Understand
beats-100-c-easy-to-understand-by-dsxoin-81kp
Complexity Time complexity: O(N) Space complexity: O(1) Code
DSxoiN9NK0
NORMAL
2025-02-05T16:35:37.371084+00:00
2025-02-05T16:35:37.371084+00:00
120
false
# Complexity - Time complexity: O(N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```cpp [] class Solution { public: int scoreOfString(string s) { int answer = 0; for(int i = 0; i < s.size() - 1; i++){ ...
2
0
['C++']
0
score-of-a-string
✅ Easiest One Liner || Beats 100% 😉
easiest-one-liner-beats-100-by-karan_agg-c11e
Code\ncpp []\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int ans=0;\n for(int i=0;i<s.length()-1;i++) ans+=abs(s[i]-s[i+1]);\n
Karan_Aggarwal
NORMAL
2024-10-07T13:36:10.525054+00:00
2024-10-07T13:36:10.525085+00:00
2
false
# Code\n```cpp []\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int ans=0;\n for(int i=0;i<s.length()-1;i++) ans+=abs(s[i]-s[i+1]);\n return ans;\n }\n};\n```\n# Upvote ? \uD83D\uDE0A
2
0
['String', 'C++']
0
score-of-a-string
JAVA SOLUTION-BEATS 99%-SINGLE LINE SOLUTION
java-solution-beats-99-single-line-solut-8ao3
\n\n# Code\njava []\nclass Solution {\n public int scoreOfString(String s) {\n int res=0;\n for(int i=0;i<s.length()-1;i++){\n res+=
THANMAYI01
NORMAL
2024-09-18T18:22:51.191731+00:00
2024-09-18T18:22:51.191768+00:00
359
false
\n\n# Code\n```java []\nclass Solution {\n public int scoreOfString(String s) {\n int res=0;\n for(int i=0;i<s.length()-1;i++){\n res+=Math.abs((s.charAt(i)-s.charAt(i+1)));\n }\n return res;\n }\n}\n```
2
0
['String', 'Java']
1
score-of-a-string
Python easy ULTRA PRO MAX Solution
python-easy-ultra-pro-max-solution-by-mi-ro0g
Code\npython3 []\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n out = 0\n for i in range(len(s) - 1):\n out += abs(ord
midhun98
NORMAL
2024-08-22T14:04:38.579053+00:00
2024-08-23T09:21:02.468085+00:00
247
false
# Code\n```python3 []\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n out = 0\n for i in range(len(s) - 1):\n out += abs(ord(s[i]) - ord(s[i + 1]))\n return out```
2
0
['Python3']
3
score-of-a-string
C# Solution for Score of a String Problem
c-solution-for-score-of-a-string-problem-c7kp
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires calculating a score for a string based on the absolute differences
Aman_Raj_Sinha
NORMAL
2024-06-01T19:16:22.944262+00:00
2024-06-01T19:16:22.944292+00:00
236
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires calculating a score for a string based on the absolute differences between the ASCII values of adjacent characters. The intuition here is to iterate through the string, compute these differences, and accumulate them t...
2
0
['C#']
0
score-of-a-string
3110. Score of a String
3110-score-of-a-string-by-sounak_12-kmsf
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\nThe given C++ function scoreOfString calculates a specific score for a
Sounak_12
NORMAL
2024-06-01T18:57:11.246045+00:00
2024-06-01T18:57:11.246081+00:00
208
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n\nThe given C++ function scoreOfString calculates a specific score for a given string s. Here is a step-by-step description of the approach:\n\nFunction Signature:\n\nThe function scoreOfString takes a single argument, a str...
2
0
['C++', 'Python3']
0
score-of-a-string
Easy and Effective Solution for Question: #3110
easy-and-effective-solution-for-question-iah8
Intuition\nHere for this question, we iterate through the characters of the string s and calculate the absolute difference between the ASCII values of adjacent
LaFlameX07
NORMAL
2024-06-01T16:56:11.641227+00:00
2024-06-01T16:56:11.641250+00:00
160
false
# Intuition\nHere for this question, we iterate through the characters of the string s and calculate the absolute difference between the ASCII values of adjacent characters. Then, we sum up these absolute differences to get the score of the string.\n# Approach\nBelow code defines a class Solution with a method scoreOfS...
2
0
['Python']
1
score-of-a-string
Beats 100% || abs() function || C++
beats-100-abs-function-c-by-batmen-wz6p
\n\n# Intuition\nabs() function is used to get absolute difference between each character and its next\n\n# Approach\nRemember to iterate only till n-2, since w
peakfor
NORMAL
2024-06-01T12:51:01.668777+00:00
2024-06-01T12:54:58.694884+00:00
0
false
![Screenshot 2024-06-01 181839.png](https://assets.leetcode.com/users/images/82d0239c-3dc6-4711-8f37-09da9e3668fa_1717246476.4011319.png)\n\n# Intuition\nabs() function is used to get absolute difference between each character and its next\n\n# Approach\nRemember to iterate only till n-2, since we we will be using i+1 ...
2
0
['C++']
0
score-of-a-string
Kotlin one line solution
kotlin-one-line-solution-by-reosfire-ssq9
Code\n\nclass Solution {\n fun scoreOfString(s: String) = s.indices.reduce { acc, i -> acc + abs(s[i] - s[i - 1]) }\n}\n
reosfire
NORMAL
2024-06-01T11:09:19.202980+00:00
2024-06-01T11:09:19.203004+00:00
53
false
# Code\n```\nclass Solution {\n fun scoreOfString(s: String) = s.indices.reduce { acc, i -> acc + abs(s[i] - s[i - 1]) }\n}\n```
2
0
['Kotlin']
0
score-of-a-string
Easy and simple Approach | Beats 99.87%
easy-and-simple-approach-beats-9987-by-k-7pjw
Intuition\nWhen I first saw this problem, I thought about a simple way to calculate the "score" of a string by comparing pairs of characters. The score calculat
kanishakpranjal
NORMAL
2024-06-01T05:56:39.444712+00:00
2024-06-01T05:56:39.444741+00:00
6
false
## Intuition\nWhen I first saw this problem, I thought about a simple way to calculate the "score" of a string by comparing pairs of characters. The score calculation involves the absolute difference between each pair of characters, and I thought we could step through the string while maintaining a counter for our answ...
2
0
['Java']
0
score-of-a-string
🔥✅Beat 100%✅|| C/C++/Java/JavaScript/Python || Full explanation✅|| Very easy approach/ Technique✅🔥
beat-100-ccjavajavascriptpython-full-exp-p830
Please upvote my solution and give a star if you like the solution...\uD83D\uDE0A\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \n
Sachin_Bhawala
NORMAL
2024-06-01T05:38:57.447331+00:00
2024-06-01T05:38:57.447366+00:00
58
false
# Please upvote my solution and give a star if you like the solution...\uD83D\uDE0A\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem "Score of a String" requires us to calculate the total score based on the differences between consecutive characters in the string. The int...
2
0
['C', 'Python', 'C++', 'Java', 'JavaScript']
1
score-of-a-string
C++ most optimal solution out there (source: trust me bro)
c-most-optimal-solution-out-there-source-tlpv
\n\n# Intuition\nidk \n\n# Approach\njust loop through one time and uhhh do the math thingy :ppp\n\n# Complexity\n- Time complexity:\nO(n) (because i said so)\n
HMinh
NORMAL
2024-06-01T05:18:58.436170+00:00
2024-06-01T05:36:20.095211+00:00
250
false
![image.png](https://assets.leetcode.com/users/images/57daae3b-7c53-41d7-9c1f-15f199ebf6f9_1717219559.0796938.png)\n\n# Intuition\nidk \n\n# Approach\njust loop through one time and uhhh do the math thingy :ppp\n\n# Complexity\n- Time complexity:\nO(n) (because i said so)\n\n- Space complexity:\nO(1); and if it happens...
2
0
['C++']
1
score-of-a-string
Simple C++ , One liner
simple-c-one-liner-by-mrigaank-ypnm
# Intuition \n\n\n# Approach\n\nSimple approach: subtract adjacent character ASCII values and add them to the count or total.\n\n# Complexity\n- Time complexi
Mrigaank
NORMAL
2024-06-01T05:05:47.011371+00:00
2024-06-01T05:05:47.011409+00:00
4
false
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSimple approach: subtract adjacent character ASCII values and add them to the count or total.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time com...
2
0
['C++']
0
score-of-a-string
💯 Beats || simple 🐣 || 4 language || Best Formatted 🫰||
beats-simple-4-language-best-formatted-b-v2kj
\n# Screenshot \uD83C\uDF89 \n\n\n\n---\n\n\n\n# Intuition \uD83D\uDCDA\n\n Given--> One String with\n \n Que description --> (2 <= s.length <= 100)\n
Prakhar-002
NORMAL
2024-06-01T04:48:51.541465+00:00
2024-06-01T04:48:51.541488+00:00
87
false
\n# Screenshot \uD83C\uDF89 \n\n![3110 c.png](https://assets.leetcode.com/users/images/592632b6-dc2c-4ef7-ab32-c31117e6e010_1717216831.3929858.png)\n\n---\n\n![3110 java.png](https://assets.leetcode.com/users/images/ff80e2d8-1bbe-4347-8385-966fda4ed0a7_1717216845.5407774.png)\n\n# Intuition \uD83D\uDCDA\n\n `Given`-...
2
0
['String', 'C', 'Java', 'Python3', 'JavaScript']
0
score-of-a-string
Easy JS Solution 🗝️😍💯
easy-js-solution-by-peermohammad-tdar
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
peermohammad
NORMAL
2024-06-01T03:37:07.510221+00:00
2024-06-01T03:37:07.510250+00:00
26
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['JavaScript']
0
score-of-a-string
Differences of adjacent characters' ASCII values. || Beats 99% users with java & c++ || typescript
differences-of-adjacent-characters-ascii-p1r9
Approach\nDifferences of adjacent characters\' ASCII values.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Explanation\n1. Initializ
SanketSawant18
NORMAL
2024-06-01T03:24:27.234669+00:00
2024-06-01T03:24:27.234691+00:00
1,142
false
# Approach\nDifferences of adjacent characters\' ASCII values.\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Explanation\n1. **Initialize totalScore:** Start with a variable totalScore set to 0. This will accumulate the sum of the absolute differences.\n\n1. **Loop through the string:** Use ...
2
0
['String', 'C++', 'Java', 'TypeScript', 'Python3']
1
score-of-a-string
Score of a string
score-of-a-string-by-karthick2605-xp27
Intuition\nThe problem involves calculating the "score" of a string, where the score is defined as the sum of the absolute differences between the ASCII values
KARTHICK2605
NORMAL
2024-06-01T02:14:30.896469+00:00
2024-06-01T02:14:30.896495+00:00
6
false
# Intuition\nThe problem involves calculating the "score" of a string, where the score is defined as the sum of the absolute differences between the ASCII values of consecutive characters. This essentially measures how "different" adjacent characters are in terms of their ASCII values.\n\n# Approach\n1. **Initialize Sc...
2
0
['String', 'Java']
1
score-of-a-string
Straightforward | C++, Python, Java
straightforward-c-python-java-by-not_yl3-7vcl
Approach\n Describe your approach to solving the problem. \nIterate through the string starting from index 1 and sum all the absolute differences (abs(s[i] - s[
not_yl3
NORMAL
2024-06-01T00:07:30.397398+00:00
2024-06-01T00:10:09.420506+00:00
477
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nIterate through the string starting from index `1` and sum all the absolute differences (`abs(s[i] - s[i-1])`).\n# Code\n```C++ []\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int sum = 0;\n for (int i = 1; i < s.lengt...
2
0
['String', 'C', 'Python', 'C++', 'Java', 'Python3']
2
score-of-a-string
Best and Easiest Explanation || C++ ✅
best-and-easiest-explanation-c-by-rckroc-ubdh
Intuition\n Describe your first thoughts on how to solve this problem. The problem requires computing a score based on the absolute differences between consecut
rckrockerz
NORMAL
2024-05-21T13:32:57.574290+00:00
2024-05-21T13:32:57.574317+00:00
26
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->The problem requires computing a score based on the absolute differences between consecutive characters in a string. This suggests a simple traversal through the string and computing the sum of these differences.\n\n# Approach\n<!-- Describ...
2
0
['C++']
0
score-of-a-string
Swift solution
swift-solution-by-azm819-lv7y
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
azm819
NORMAL
2024-05-05T13:24:48.296023+00:00
2024-05-05T13:24:48.296056+00:00
114
false
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func scoreOfString(_ s: String) -> Int {\n var result = 0\n var firstInd = s.startI...
2
0
['String', 'Swift']
0
score-of-a-string
✔️✔️✔️very easy solution - for loop - PYTHON || C++ || JAVA - beats 100%⚡⚡⚡
very-easy-solution-for-loop-python-c-jav-o8qz
Code\nPython []\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n fin = 0\n for i in range(len(s) - 1):\n fin += abs(ord(
anish_sule
NORMAL
2024-04-22T13:55:04.331973+00:00
2024-04-22T13:55:04.332015+00:00
95
false
# Code\n```Python []\nclass Solution:\n def scoreOfString(self, s: str) -> int:\n fin = 0\n for i in range(len(s) - 1):\n fin += abs(ord(s[i]) - ord(s[i+1]))\n return fin\n```\n```C++ []\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int fin = 0;\n for(i...
2
0
['String', 'C++', 'Java', 'Python3']
1
score-of-a-string
👏Beats 99.97% of users with Java
beats-9997-of-users-with-java-by-iamrjb1-26yy
\n# Code\n\nclass Solution {\n public int scoreOfString(String s) {\n int sum=0;\n for(int i=0;i<s.length()-1;i++){\n sum+= Math.abs
iamrjb11
NORMAL
2024-04-22T09:46:31.018591+00:00
2024-04-22T09:46:31.018620+00:00
44
false
\n# Code\n```\nclass Solution {\n public int scoreOfString(String s) {\n int sum=0;\n for(int i=0;i<s.length()-1;i++){\n sum+= Math.abs(s.charAt(i)-s.charAt(i+1));\n }\n return sum; \n }\n}\n```\n# Please upvote \uD83D\uDC46
2
0
['Java']
0
score-of-a-string
Swift💯
swift-by-upvotethispls-k9u4
Functional approach (accepted answer)\n\nimport Algorithms\n\nclass Solution {\n func scoreOfString(_ s: String) -> Int {\n s.utf8CString //
UpvoteThisPls
NORMAL
2024-04-16T20:12:54.750636+00:00
2024-06-01T00:47:10.202149+00:00
26
false
**Functional approach (accepted answer)**\n```\nimport Algorithms\n\nclass Solution {\n func scoreOfString(_ s: String) -> Int {\n s.utf8CString // convert `s` into `[CChar]` (`CChar` is typealias for `UInt8`)\n\t\t .dropLast() // drop the zero-terminator that is added to the C string\n\t\t...
2
0
['Swift']
0
score-of-a-string
✅ FP Style
fp-style-by-eleev-j4dm
Solution\n##### #1\n\n`FP` + `.utf8CString` = more performant\n\nswift\nstruct Solution {\n @_optimize(speed)\n func scoreOfString(_ s: String) -> Int {\n
eleev
NORMAL
2024-04-16T15:43:42.898626+00:00
2024-07-25T12:40:42.333592+00:00
84
false
# Solution\n##### #1\n```\n`FP` + `.utf8CString` = more performant\n```\n```swift\nstruct Solution {\n @_optimize(speed)\n func scoreOfString(_ s: String) -> Int {\n let codes = s.utf8CString.dropLast()\n return codes.indices[1...].reduce(0) { score, i in\n score + abs(Int(codes[i] - code...
2
0
['String', 'Swift']
1
score-of-a-string
Ruby one-liner, beats 100%/100%
ruby-one-liner-beats-100100-by-dnnx-f3zb
\n# @param {String} s\n# @return {Integer}\ndef score_of_string(s)\n s.bytes.each_cons(2).sum { (_1 - _2).abs } \nend\n
dnnx
NORMAL
2024-04-15T18:46:22.673569+00:00
2024-04-15T18:46:22.673600+00:00
26
false
```\n# @param {String} s\n# @return {Integer}\ndef score_of_string(s)\n s.bytes.each_cons(2).sum { (_1 - _2).abs } \nend\n```
2
0
['Ruby']
0
score-of-a-string
One liner 0ms
one-liner-0ms-by-marktyrkba-fd01
Code\n\nimpl Solution {\n pub fn score_of_string(s: String) -> i32 {\n s\n .chars()\n .collect::<Vec<_>>()\n .windows(2)\n
marktyrkba
NORMAL
2024-04-13T18:26:58.497265+00:00
2024-04-13T18:26:58.497296+00:00
173
false
# Code\n```\nimpl Solution {\n pub fn score_of_string(s: String) -> i32 {\n s\n .chars()\n .collect::<Vec<_>>()\n .windows(2)\n .map(|w| (w[1] as i32 - w[0] as i32).abs())\n .sum::<i32>()\n }\n}\n```
2
0
['Rust']
0
score-of-a-string
Simple cpp solution
simple-cpp-solution-by-vaibhav_2077-4j6n
\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int sum=0;\n for(int i=0;i<s.size()-1;i++){\n sum+=abs(static_cast<int
vaibhav_2077
NORMAL
2024-04-13T16:09:54.889482+00:00
2024-04-13T16:09:54.889509+00:00
1,148
false
```\nclass Solution {\npublic:\n int scoreOfString(string s) {\n int sum=0;\n for(int i=0;i<s.size()-1;i++){\n sum+=abs(static_cast<int>(s[i]) - static_cast<int>(s[i + 1]));\n }\n return sum;\n }\n};``\n```
2
0
['C++']
1
score-of-a-string
simple solution with 100% beat
simple-solution-with-100-beat-by-vinay_k-fwwi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
vinay_kumar_swami
NORMAL
2024-04-13T16:07:48.283119+00:00
2024-04-13T16:07:48.283152+00:00
128
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
1
score-of-a-string
Beats 100% | counting |Easy Java Solution
beats-100-counting-easy-java-solution-by-205u
\n\n# Code\n\nclass Solution {\n public int scoreOfString(String s) {\n int ans = 0;\n \n for(int i=0;i<s.length()-1;i++){\n
Ikapoor123
NORMAL
2024-04-13T16:05:23.952290+00:00
2024-04-13T16:05:23.952316+00:00
1,995
false
\n\n# Code\n```\nclass Solution {\n public int scoreOfString(String s) {\n int ans = 0;\n \n for(int i=0;i<s.length()-1;i++){\n ans+=Math.abs(s.charAt(i)-s.charAt(i+1));\n }\n return ans;\n }\n}\n```
2
0
['Array', 'C', 'Python', 'C++', 'Java', 'TypeScript', 'Python3', 'Ruby', 'Kotlin', 'JavaScript']
2
score-of-a-string
[Python3] One Line - Simple Solution
python3-one-line-simple-solution-by-dolo-ghco
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
dolong2110
NORMAL
2024-04-13T16:02:27.025831+00:00
2024-05-03T03:21:34.937533+00:00
55
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N)$$\n<!-- Add your space complexity here...
2
0
['String', 'Python3']
1
score-of-a-string
easy solution
easy-solution-by-haneen_ep-4dto
IntuitionApproachComplexity Time complexity: Space complexity: Code
haneen_ep
NORMAL
2025-04-09T08:46:35.192375+00:00
2025-04-09T08:46:35.192375+00:00
18
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['JavaScript']
0
score-of-a-string
1 ms Beats 99.49% | 41.64 MB Beats 98.46%
1-ms-beats-9949-4164-mb-beats-9846-by-gu-s7bv
IntuitionThe problem requires calculating the total "score" of a string based on the absolute difference in ASCII values between each pair of adjacent character
gunanshu_joshi
NORMAL
2025-04-07T03:22:56.829425+00:00
2025-04-07T03:22:56.829425+00:00
47
false
# Intuition The problem requires calculating the total "score" of a string based on the absolute difference in ASCII values between each pair of adjacent characters. My first thought was to iterate through the string and compute the difference in ASCII values between consecutive characters. Since ASCII values are int...
1
0
['Java']
0
score-of-a-string
0 ms | Beats 100.00% | Easy and Effective Code
0-ms-beats-10000-easy-and-effective-code-r7h5
Code
R_Nirmal_Rajan
NORMAL
2025-04-06T09:48:00.383981+00:00
2025-04-06T09:48:00.383981+00:00
76
false
# Code ```python3 [] class Solution: def scoreOfString(self, s: str) -> int: result = 0 for j in range(len(s)): if j < (len(s)-1): process = abs(ord(s[j]) - ord(s[j+1])) result += process return result ``` ![Screenshot (178).png](https://assets.lee...
1
0
['String', 'Python3']
0
score-of-a-string
bEAts 100% aNd eASy sOlutioN iN cPp.
beats-100-and-easy-solution-in-cpp-by-xe-nuly
IntuitionApproachComplexity Time complexity:O(n) Space complexity:O(1) Code
xegl87zdzE
NORMAL
2025-04-02T13:18:11.022177+00:00
2025-04-02T13:18:11.022177+00:00
50
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity:O(n) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> ...
1
0
['String', 'C++']
0
score-of-a-string
Simple thought...
simple-thought-by-1zkmhmzztg-yvin
IntuitionThe problem requires us to calculate the sum of the absolute differences between the ASCII values of adjacent characters in a string. Since the ASCII v
1ZkMHmzzTG
NORMAL
2025-04-01T14:41:51.402776+00:00
2025-04-01T14:41:51.402776+00:00
52
false
# Intuition The problem requires us to calculate the sum of the absolute differences between the ASCII values of adjacent characters in a string. Since the ASCII value of a character can be obtained using ord(), we can iterate through the string, compute these differences, and accumulate the sum. <!-- Describe your fir...
1
0
['Python3']
0
score-of-a-string
Java Solution Runtime Beats 99.43% Memory Beats 91.84%
java-solution-runtime-beats-9943-memory-ai8ov
ApproachConverting string to CharArray to find char faster by indexComplexity Time complexity: O(n) Space complexity: O(n) and still faster:) Code
yorick_yeng
NORMAL
2025-03-31T21:47:05.704451+00:00
2025-03-31T21:47:05.704451+00:00
7
false
<!-- # Intuition --> <!-- Describe your first thoughts on how to solve this problem. --> # Approach Converting string to CharArray to find char faster by index <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: $$O(n)$$ <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Spa...
1
0
['Java']
0
score-of-a-string
One String Kotlin Solution :)
one-string-kotlin-solution-by-yorick_yen-2cr0
ApproachGetting the sum of absolute difference between two adjacent charsComplexity Time complexity: O(n) Space complexity: O(1) Code
yorick_yeng
NORMAL
2025-03-31T21:40:24.068791+00:00
2025-03-31T21:40:24.068791+00:00
4
false
<!-- # Intuition --> <!-- Describe your first thoughts on how to solve this problem. --> # Approach Getting the sum of absolute difference between two adjacent chars <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: $$O(n)$$ <!-- Add your time complexity here, e.g. $$O(n)$$ --> ...
1
0
['Kotlin']
0
score-of-a-string
C++ Easy Sol
c-easy-sol-by-maaz_ali27-hnlx
IntuitionApproachComplexity Time complexity: Space complexity: Code
Maaz_Ali27
NORMAL
2025-03-21T11:33:58.818669+00:00
2025-03-21T11:33:58.818669+00:00
74
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['C++']
0
score-of-a-string
YOU NEED SOLUTION HUH ?
you-need-solution-huh-by-bruteforceenjoy-ubgw
BRO, HOW IS THIS EVEN CONFUSING ?Code
BruteForceEnjoyer
NORMAL
2025-03-19T01:47:06.366952+00:00
2025-03-19T01:49:40.236972+00:00
52
false
# BRO, HOW IS THIS EVEN CONFUSING ? # Code ```cpp [] class Solution { public: int scoreOfString(string s) { int res = 0; for ( int i = 0 ; i < s.size() - 1 ; i ++ ){ res += max(s[i] , s[i+1] ) - min ( s[i] , s[i+1] ); } return res; } }; ```
1
0
['String', 'C++']
0
score-of-a-string
One liner using ord() and sum() in python
one-liner-using-ord-and-sum-in-python-by-6zkk
IntuitionApproachComplexity Time complexity: Space complexity: Code
rMSxyPSgWL
NORMAL
2025-03-18T10:01:32.049828+00:00
2025-03-18T10:01:32.049828+00:00
56
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['Python3']
0
score-of-a-string
String Score Calculation Using ASCII Differences
string-score-calculation-using-ascii-dif-p8zg
IntuitionThe problem requires calculating a "score" for a given string based on the absolute difference between adjacent character ASCII values. By iterating th
expert07
NORMAL
2025-03-06T06:13:29.052246+00:00
2025-03-06T06:13:29.052246+00:00
100
false
# Intuition The problem requires calculating a "score" for a given string based on the absolute difference between adjacent character ASCII values. By iterating through the string and summing these differences, we obtain the final score. This approach efficiently captures variations in character sequences. # Approach ...
1
0
['Math', 'String', 'Iterator', 'C++']
0
score-of-a-string
Easy Java Solution
easy-java-solution-by-vermaanshul975-4j7f
IntuitionApproachComplexity Time complexity: O(N) Space complexity: O(1) Code
vermaanshul975
NORMAL
2025-03-02T09:04:50.813613+00:00
2025-03-02T09:04:50.813613+00:00
116
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ -->...
1
0
['Java']
0
score-of-a-string
Codegolf-like solution
codegolf-like-solution-by-atiedebee-261x
Not really "code golf" by most peoples standards, but I imagine it looks really strange to people unfamiliar with C.Code
atiedebee
NORMAL
2025-03-01T17:56:39.980375+00:00
2025-03-01T17:56:39.980375+00:00
24
false
Not really "code golf" by most peoples standards, but I imagine it looks really strange to people unfamiliar with C. # Code ```c [] int scoreOfString(char* s) { int sum = 0; while(*++s){ sum += s[-1] > s[0] ? s[-1] - s[0] : s[0] - s[-1]; } return sum; } ```
1
0
['C']
0
score-of-a-string
C#
c-by-adchoudhary-fhuq
Code
adchoudhary
NORMAL
2025-02-26T04:11:41.680444+00:00
2025-02-26T04:11:41.680444+00:00
42
false
# Code ```csharp [] public class Solution { public int ScoreOfString(string s) { int score = 0; // Iterate over all indices from 0 to the second-to-last index // Calculate and accumulate the absolute difference of ASCII values // between adjacent characters for (int i = 0; i ...
1
0
['C#']
0
score-of-a-string
"Easy" C++ Code for Score Of String Beats 100%
easy-c-code-for-score-of-string-beats-10-y9r5
Intuitioncomapring current and adjacent string character.Approachcomapring current and adjacent string character and subtracting their ASCII values and storing
Sumit22_LC
NORMAL
2025-02-09T18:29:38.478230+00:00
2025-02-09T18:29:38.478230+00:00
79
false
# Intuition comapring current and adjacent string character. # Approach comapring current and adjacent string character and subtracting their ASCII values and storing them into a variable and returning it. # Complexity - Time complexity: O(n) - Space complexity: O(1) # Code ```cpp [] class Solution { public: in...
1
0
['C++']
1
score-of-a-string
Here's The Solution in Java
heres-the-solution-in-java-by-harishkann-caxg
IntuitionApproachComplexity Time complexity: Space complexity: Code
harishkannan05
NORMAL
2025-01-28T10:12:06.745134+00:00
2025-01-28T10:12:06.745134+00:00
136
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['Java']
0
score-of-a-string
Solution for Score of a String
solution-for-score-of-a-string-by-abhina-zg18
IntuitionI thought about creating an array and storing all the ascii values of the characters and then using them to evaluate the score.ApproachI did the questi
AbhinavGupta012
NORMAL
2025-01-27T08:52:58.477448+00:00
2025-01-27T08:52:58.477448+00:00
64
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> I thought about creating an array and storing all the ascii values of the characters and then using them to evaluate the score. # Approach <!-- Describe your approach to solving the problem. --> I did the question using Brute-Force Approac...
1
0
['Java']
0
score-of-a-string
simple solution
simple-solution-by-lathika17-sqpn
IntuitionApproachComplexity Time complexity: Space complexity: Code
lathika17
NORMAL
2025-01-19T10:49:52.418596+00:00
2025-01-19T10:49:52.418596+00:00
51
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['JavaScript']
0
score-of-a-string
last submission beat 100% of other submissions' runtime || easy and simplle approach || o(n)||c++||
last-submission-beat-100-of-other-submis-gonh
IntuitionApproachComplexity Time complexity: Space complexity: Code
Rohan07_6473
NORMAL
2025-01-16T17:35:52.771960+00:00
2025-01-16T17:35:52.771960+00:00
74
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['C++']
0
score-of-a-string
Single line solution || Python || Super fast, beats 100% in run time || Easy solution
single-line-solution-python-super-fast-b-0g40
Code
sheshan25
NORMAL
2025-01-15T20:37:54.264755+00:00
2025-01-15T20:37:54.264755+00:00
90
false
# Code ```python3 [] class Solution: def scoreOfString(self, s: str) -> int: return sum(abs(ord(s[i-1]) - ord(s[i])) for i in range(1, len(s))) ```
1
0
['Python3']
0