Skip to content

Commit

Permalink
Add some code
Browse files Browse the repository at this point in the history
  • Loading branch information
codeAbinash committed Jun 2, 2024
1 parent b5d8a43 commit 3c604b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions leetcode/problems/java/reverse-string.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution {
public void reverseString(char[] s) {
int n = s.length;
for (int i = 0; i < n / 2; i++) {
char temp = s[i];
s[i] = s[n - i - 1];
s[n - i - 1] = temp;
}
}
}
11 changes: 11 additions & 0 deletions leetcode/problems/java/score-of-a-string.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution {
public int scoreOfString(String s) {
int score = 0;
int n = s.length();
for (int i = 0; i < n - 1; i++) {
int diff = Math.abs(s.charAt(i + 1) - s.charAt(i));
score += diff;
}
return score;
}
}

0 comments on commit 3c604b1

Please sign in to comment.