777. Swap Adjacent in LR String Medium
1/**
2 * [777] Swap Adjacent in LR String
3 *
4 * In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string end, return True if and only if there exists a sequence of moves to transform one string to the other.
5 *
6 * Example 1:
7 *
8 * Input: start = "RXXLRXRXL", end = "XRLXXRRLX"
9 * Output: true
10 * Explanation: We can transform start to end following these steps:
11 * RXXLRXRXL ->
12 * XRXLRXRXL ->
13 * XRLXRXRXL ->
14 * XRLXXRRXL ->
15 * XRLXXRRLX
16 *
17 * Example 2:
18 *
19 * Input: start = "X", end = "L"
20 * Output: false
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= start.length <= 10^4
26 * start.length == end.length
27 * Both start and end will only consist of characters in 'L', 'R', and 'X'.
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/swap-adjacent-in-lr-string/
33// discuss: https://leetcode.com/problems/swap-adjacent-in-lr-string/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn can_transform(start: String, end: String) -> bool {
39 false
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_777() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.