We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 899283f commit 704da9fCopy full SHA for 704da9f
2833.Furthest-point-from-origin.java
@@ -0,0 +1,31 @@
1
+// https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/description/
2
+// algorithms
3
+// Easy (63.24%)
4
+// Total Accepted: 38.7K
5
+// Total Submissions: 61.2K
6
+
7
+class Solution {
8
9
+ private static final char L = 'L';
10
+ private static final char R = 'R';
11
+ private static final char ANY = '_';
12
13
+ public int furthestDistanceFromOrigin(String moves) {
14
+ int lNum = 0;
15
+ int rNum = 0;
16
+ int anyNum = 0;
17
18
+ for (char ch : moves.toCharArray()) {
19
+ if (L == ch) {
20
+ lNum++;
21
+ } else if (R == ch) {
22
+ rNum++;
23
+ } else if (ANY == ch) {
24
+ anyNum++;
25
+ }
26
27
28
+ return Math.abs(lNum - rNum) + anyNum;
29
30
31
+}
0 commit comments