Skip to content

Commit 608019c

Browse files
committed
feat: add python solution for lcci problem
1 parent 651425c commit 608019c

File tree

5 files changed

+71
-8
lines changed

5 files changed

+71
-8
lines changed

lcci/README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# 《程序员面试金典》系列
2-
地址:https://leetcode-cn.com/problemset/lcci/
1+
# [《程序员面试金典(第 6 版)》系列](https://leetcode-cn.com/problemset/lcci/)
2+
本书是原谷歌资深面试官的经验之作,帮助了许多想要加入脸书、苹果、谷歌等 IT 名企的求职者拿到 Dream offer。本专题的 100+ 编程面试题是在原书基础上精心挑选出来的,帮助你轻松应战 IT 名企技术面试。
3+
4+
## [题解](https://github.com/doocs/leetcode/tree/master/lcci)
35

4-
## 题解
56
```
67
.
78
├── README.md
@@ -13,4 +14,7 @@
1314
└── 面试题 01.02. 判定是否互为字符重排
1415
├── README.md
1516
└── Solution.py
16-
```
17+
```
18+
19+
## 版权
20+
商业转载请联系 [@yanglbme](https://github.com/yanglbme) 授权,非商业转载请注明出处。
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# [面试题 01.03. URL化](https://leetcode-cn.com/problems/string-to-url-lcci/)
2+
3+
## 题目描述
4+
URL化。编写一种方法,将字符串中的空格全部替换为 `%20`。假定该字符串尾部有足够的空间存放新增字符,并且知道字符串的“真实”长度。(注:用 `Java` 实现的话,请使用字符数组实现,以便直接在数组上操作。)
5+
6+
**示例1:**
7+
8+
```
9+
输入:"Mr John Smith ", 13
10+
输出:"Mr%20John%20Smith"
11+
```
12+
13+
**示例2:**
14+
15+
```
16+
输入:" ", 5
17+
输出:"%20%20%20%20%20"
18+
```
19+
20+
**提示:**
21+
22+
1. 字符串长度在[0, 500000]范围内。
23+
24+
## 解法
25+
### Python3
26+
```python
27+
class Solution:
28+
def replaceSpaces(self, S: str, length: int) -> str:
29+
S = S[:length] if length < len(S) else S
30+
return S.replace(' ', '%20')
31+
```
32+
33+
### Java
34+
```java
35+
36+
```
37+
38+
### ...
39+
```
40+
41+
```
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Solution:
2+
def replaceSpaces(self, S: str, length: int) -> str:
3+
S = S[:length] if length < len(S) else S
4+
return S.replace(' ', '%20')

lcof/README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# 《剑指 Offer》系列
2-
地址:https://leetcode-cn.com/problemset/lcof/
1+
# [《剑指 Offer(第 2 版)》系列](https://leetcode-cn.com/problemset/lcof/)
2+
本书精选谷歌、微软等知名IT企业的典型面试题,系统地总结了如何在面试时写出高质量代码,如何优化代码效率,以及分析、解决难题的常用方法。
3+
4+
## [题解](https://github.com/doocs/leetcode/tree/master/lcci)
35

4-
## 题解
56
```
67
.
78
├── README.md
89
├── template.md
910
└── 面试题03. 数组中重复的数字
1011
├── README.md
1112
└── Solution.py
12-
```
13+
```
14+
15+
## 版权
16+
商业转载请联系 [@yanglbme](https://github.com/yanglbme) 授权,非商业转载请注明出处。

lcof/面试题03. 数组中重复的数字/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ class Solution:
3232
nums[i], nums[num] = nums[num], nums[i]
3333

3434
```
35+
36+
### Java
37+
```java
38+
39+
```
40+
41+
### ...
42+
```
43+
44+
```

0 commit comments

Comments
 (0)