-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFARorign.cpp
More file actions
31 lines (28 loc) · 863 Bytes
/
Copy pathFARorign.cpp
File metadata and controls
31 lines (28 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
int furthestDistanceFromOrigin(string moves) {
int n = moves.size();
// int ans=0 , j = 0 , x = INT_MIN;
int l =0 , r = 0 , blank = 0 ;
for (int i =0 ; i < n ; i++){
if (moves[i]=='L') l++;
if (moves[i]=='R') r++;
if (moves[i]=='_') blank++;
}
return abs(l-r) +blank;
}
};
// if ( moves[i]=='R' || moves[i+1]=='_' || moves[i]=='_' ){
// ans++;
// }
// else if ( moves[i]=='L' || moves[i+1]=='_' || moves[i]=='_' ){
// ans++;
// }
// if (moves[i]==_ || moves[i]==R ){
// ans++;
// }
// if (moves[i]==L || moves[i+1]==_ ){
// ans++;
// }