Skip to content

Commit 0512e06

Browse files
authored
Merge pull request #4200 from CodeHarborHub/restyled/dev-3
Restyle update and fix bug
2 parents 43ac5a4 + 4cbbe68 commit 0512e06

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

dsa-solutions/lc-solutions/0100-0199/0171-excel-sheet-column-number.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,16 @@ AB -> 28
2323

2424
**Example 1:**
2525

26-
2726
**Example 2:**
2827

29-
3028
**Example 3:**
3129

32-
33-
3430
## Solution for Best Time to Buy and Sell Stock Problem
3531

3632
### Intuition
3733

3834
The intuition behind the solution is to treat each letter as a digit in a base-26 number system, where 'A' represents 1, 'B' represents 2, ..., 'Z' represents 26. The solution then iterates through each character in the column title, calculates the numeric value of the corresponding letter, and accumulates the result by considering the positional weight of each letter.
3935

40-
4136
- Initialize variables x and ans to keep track of the positional weight and the accumulated result, respectively.
4237
- Iterate through each character s in the columnTitle.
4338
- Convert the character s to its numeric representation by using the ord function (ASCII value) and subtracting 64 (since 'A' corresponds to 65 in ASCII).
@@ -81,10 +76,10 @@ class Solution:
8176
x -= 1
8277

8378
return ans
84-
79+
8580
```
8681

8782
### Complexity Analysis
8883

8984
- Time complexity: $O(n)$
90-
- Space complexity: $O(1)$
85+
- Space complexity: $O(1)$

0 commit comments

Comments
 (0)