Skip to content

Commit 0750ee3

Browse files
Update 3106- Lexicographically Smallest String After Operations With Constraint.md
1 parent cd0ae9f commit 0750ee3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dsa-solutions/lc-solutions/3100-3199/3106- Lexicographically Smallest String After Operations With Constraint.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ string `t` you can get after some changes, such that `distance(s, t) <= k`.
3030

3131
**Example 1:**
3232

33-
**Input:** s = "zbbz", k = 3
33+
**Input:** `s = "zbbz"`, `k = 3`
3434

3535
**Output:** "aaaz"
3636

3737
**Explanation:**
3838

39-
Change s to "aaaz". The distance between "zbbz" and "aaaz" is equal to k = 3.
39+
Change s to "aaaz". The distance between "zbbz" and "aaaz" is equal to `k = 3`.
4040

4141
**Example 2:**
4242

43-
**Input:** s = "xaxcd", k = 4
43+
**Input:** `s = "xaxcd"`, `k = 4`
4444

4545
**Output:** "aawcd"
4646

4747
**Explanation:**
4848

49-
The distance between "xaxcd" and "aawcd" is equal to k = 4.
49+
The distance between "xaxcd" and "aawcd" is equal to `k = 4`.
5050

5151

5252
### Constraints
@@ -61,7 +61,7 @@ The distance between "xaxcd" and "aawcd" is equal to k = 4.
6161

6262
## 1. Conversion to Character Array:
6363

64-
char[] result = s.toCharArray();: This line converts the input string s into a character array named result. This array will hold the modified string.
64+
char[] `result = s.toCharArray()`;: This line converts the input string s into a character array named result. This array will hold the modified string.
6565

6666
## 2. Iterating Through Characters:
6767

@@ -75,11 +75,11 @@ An inner for loop iterates through all lowercase letters `char c = 'a'; c <= 'z'
7575
- **distance(s.charAt(i), c):**
7676
This calculates the distance between the current character s[i] and the candidate replacement character c using a separate distance function (assumed to be defined elsewhere).
7777

78-
- **if (distance(s.charAt(i), c) <= k):** This checks if changing the current character to c is allowed within the k limit based on the distance.
78+
- **if `(distance(s.charAt(i), c) <= k):`** This checks if changing the current character to c is allowed within the k limit based on the distance.
7979

8080
**If the distance is less than or equal to k:**
81-
- result[i] = c;: The character in the result array at position i is updated with the new character c.
82-
- k -= distance(s.charAt(i), c);: The remaining allowed changes (k) are decremented by the distance used for this replacement.
81+
- `result[i] = c`;: The character in the result array at position i is updated with the new character c.
82+
- `k -= distance(s.charAt(i), c)`;: The remaining allowed changes (k) are decremented by the distance used for this replacement.
8383
- break;: The inner loop exits as a suitable replacement has been found within the limit.
8484

8585
## 4. Returning the Modified String:

0 commit comments

Comments
 (0)