Skip to content

Commit

Permalink
feat: generate readme files for lcci questions
Browse files Browse the repository at this point in the history
生成《程序员面试金典》题目文档
  • Loading branch information
yanglbme committed Mar 18, 2020
1 parent 8ec3e05 commit 066e76b
Show file tree
Hide file tree
Showing 253 changed files with 10,688 additions and 953 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
<a href="https://github.com/doocs/leetcode/issues"><img src="https://badgen.net/github/open-issues/doocs/leetcode" alt="issues"></a>
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode.svg" alt="forks"></a>
<a href="https://github.com/doocs/leetcode/blob/master/LICENSE"><img src="https://badgen.net/github/license/doocs/leetcode?color=green" alt="LICENSE"></a><br>
<a href="https://github.com/doocs/leetcode" alt="github"><img src="https://badgen.net/badge/⭐/GitHub/cyan" /></a>
<a href="https://gitee.com/doocs/leetcode" alt="gitee"><img src="https://badgen.net/badge/⭐/Gitee/cyan" /></a>
<!-- <a href="https://github.com/doocs/leetcode" alt="github"><img src="https://badgen.net/badge/⭐/GitHub/cyan" /></a>
<a href="https://gitee.com/doocs/leetcode" alt="gitee"><img src="https://badgen.net/badge/⭐/Gitee/cyan" /></a> -->
<a href="http://makeapullrequest.com"><img src="https://badgen.net/badge/PRs/welcome/cyan" alt="PRs Welcome"></a>
<a href="https://doocs.github.io/#/?id=how-to-join"><img src="https://badgen.net/badge/organization/join%20us/cyan" alt="open-source-organization"></a>
</p>

## 介绍
本项目包含 [LeetCode](https://leetcode-cn.com/problemset/all/)[《剑指 Offer(第 2 版)》](https://leetcode-cn.com/problemset/lcof/)[《程序员面试金典(第 6 版)》](https://leetcode-cn.com/problemset/lcci/)等题目的相关题解。所有题解均由多种编程语言实现,包括但不限于:Java、Python、C++、JavaScript、C#、Go,日常更新。

[English Version](./README_EN.md)
[English Version](/README_EN.md)

## 站点
- Gitee Pages: https://doocs.gitee.io/leetcode
- GitHub Pages: https://doocs.github.io/leetcode
<!-- - Gitee Pages: https://doocs.gitee.io/leetcode
- GitHub Pages: https://doocs.github.io/leetcode -->

注:对于国内(中国)的朋友,访问 Gitee Pages 速度会相对快一些。
<!-- 注:对于国内(中国)的朋友,访问 Gitee Pages 速度会相对快一些。 -->
https://doocs.github.io/leetcode/#/README_EN

## 题解
- [LeetCode](./solution/README.md)
Expand Down
11 changes: 6 additions & 5 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
<a href="https://github.com/doocs/leetcode/issues"><img src="https://badgen.net/github/open-issues/doocs/leetcode" alt="issues"></a>
<a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode.svg" alt="forks"></a>
<a href="https://github.com/doocs/leetcode/blob/master/LICENSE"><img src="https://badgen.net/github/license/doocs/leetcode?color=green" alt="LICENSE"></a><br>
<a href="https://github.com/doocs/leetcode" alt="github"><img src="https://badgen.net/badge/⭐/GitHub/cyan" /></a>
<a href="https://gitee.com/doocs/leetcode" alt="gitee"><img src="https://badgen.net/badge/⭐/Gitee/cyan" /></a>
<!-- <a href="https://github.com/doocs/leetcode" alt="github"><img src="https://badgen.net/badge/⭐/GitHub/cyan" /></a>
<a href="https://gitee.com/doocs/leetcode" alt="gitee"><img src="https://badgen.net/badge/⭐/Gitee/cyan" /></a> -->
<a href="http://makeapullrequest.com"><img src="https://badgen.net/badge/PRs/welcome/cyan" alt="PRs Welcome"></a>
<a href="https://doocs.github.io/#/?id=how-to-join"><img src="https://badgen.net/badge/organization/join%20us/cyan" alt="open-source-organization"></a>
</p>

## Introduction
Complete solutions to [LeetCode](https://leetcode-cn.com/problemset/all/), [LCOF](https://leetcode-cn.com/problemset/lcof/) and [LCCI](https://leetcode-cn.com/problemset/lcci/) problems, updated daily.

[中文文档](./README.md)
[中文文档](/README.md)

## Sites
- Gitee Pages: https://doocs.gitee.io/leetcode
- GitHub Pages: https://doocs.github.io/leetcode
<!-- - Gitee Pages: https://doocs.gitee.io/leetcode
- GitHub Pages: https://doocs.github.io/leetcode -->
https://doocs.gitee.io/leetcode

## Solutions
- [LeetCode](./solution/README.md)
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
} else {
url = 'https://github.com/doocs/leetcode/blob/master/' + vm.route.file
}
var editHtml = '[:memo: 在 GitHub 编辑](' + url + ')\n'
var editHtml = '[:memo: Edit on GitHub](' + url + ')\n'
return editHtml + html
})
},
Expand Down
63 changes: 63 additions & 0 deletions lcci/01.01.Is Unique/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# [面试题 01.01. 判定字符是否唯一](https://leetcode-cn.com/problems/is-unique-lcci)

## 题目描述
<!-- 这里写题目描述 -->
<p>实现一个算法,确定一个字符串 <code>s</code> 的所有字符是否全都不同。</p>

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong> <code>s</code> = &quot;leetcode&quot;
<strong>输出:</strong> false
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong> <code>s</code> = &quot;abc&quot;
<strong>输出:</strong> true
</pre>

<p><strong>限制:</strong></p>
<ul>
<li><code>0 <= len(s) <= 100 </code></li>
<li>如果你不使用额外的数据结构,会很加分。</li>
</ul>


## 解法
<!-- 这里可写通用的实现逻辑 -->


### Python3
<!-- 这里可写当前语言的特殊实现逻辑 -->

```python
class Solution:
def isUnique(self, astr: str) -> bool:
sets = set(astr)
return len(sets) == len(astr)
```

### Java
<!-- 这里可写当前语言的特殊实现逻辑 -->

```java
class Solution {
public boolean isUnique(String astr) {
char[] chars = astr.toCharArray();
int len = chars.length;
for (int i = 0; i < len - 1; ++i) {
for (int j = i + 1; j < len; ++j) {
if (chars[i] == chars[j]) {
return false;
}
}
}
return true;
}
}
```

### ...
```
```
87 changes: 87 additions & 0 deletions lcci/01.01.Is Unique/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# [01.01. Is Unique](https://leetcode-cn.com/problems/is-unique-lcci)

## Description
<p>Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?</p>



<p><strong>Example 1:</strong></p>



<pre>

<strong>Input: </strong><code>s</code> = &quot;leetcode&quot;

<strong>Output: </strong>false

</pre>



<p><strong>Example 2:</strong></p>



<pre>

<strong>Input: </strong><code>s</code> = &quot;abc&quot;

<strong>Output: </strong>true

</pre>



<p>&nbsp;</p>



<p><strong>Note:</strong></p>



<ul>

<li><code>0 &lt;= len(s) &lt;= 100 </code></li>

</ul>




## Solutions


### Python3

```python
class Solution:
def isUnique(self, astr: str) -> bool:
sets = set(astr)
return len(sets) == len(astr)
```

### Java

```java
class Solution {
public boolean isUnique(String astr) {
char[] chars = astr.toCharArray();
int len = chars.length;
for (int i = 0; i < len - 1; ++i) {
for (int j = i + 1; j < len; ++j) {
if (chars[i] == chars[j]) {
return false;
}
}
}
return true;
}
}
```

### ...
```
```
50 changes: 50 additions & 0 deletions lcci/01.02.Check Permutation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# [面试题 01.02. 判定是否互为字符重排](https://leetcode-cn.com/problems/check-permutation-lcci)

## 题目描述
<!-- 这里写题目描述 -->
<p>给定两个字符串 <code>s1</code> 和 <code>s2</code>,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。</p>

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong> <code>s1</code> = &quot;abc&quot;, <code>s2</code> = &quot;bca&quot;
<strong>输出:</strong> true
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong> <code>s1</code> = &quot;abc&quot;, <code>s2</code> = &quot;bad&quot;
<strong>输出:</strong> false
</pre>

<p><strong>说明:</strong></p>

<ul>
<li><code>0 &lt;= len(s1) &lt;= 100 </code></li>
<li><code>0 &lt;= len(s2) &lt;= 100 </code></li>
</ul>


## 解法
<!-- 这里可写通用的实现逻辑 -->


### Python3
<!-- 这里可写当前语言的特殊实现逻辑 -->

```python
class Solution:
def CheckPermutation(self, s1: str, s2: str) -> bool:
return sorted(s1) == sorted(s2)
```

### Java
<!-- 这里可写当前语言的特殊实现逻辑 -->

```java

```

### ...
```
```
71 changes: 71 additions & 0 deletions lcci/01.02.Check Permutation/README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# [01.02. Check Permutation](https://leetcode-cn.com/problems/check-permutation-lcci)

## Description
<p>Given two strings,write a method to decide if one is a permutation of the other.</p>



<p><strong>Example 1:</strong></p>



<pre>

<strong>Input: </strong><code>s1</code> = &quot;abc&quot;, <code>s2</code> = &quot;bca&quot;

<strong>Output: </strong>true

</pre>



<p><strong>Example 2:</strong></p>



<pre>

<strong>Input: </strong><code>s1</code> = &quot;abc&quot;, <code>s2</code> = &quot;bad&quot;

<strong>Output: </strong>false

</pre>



<p><strong>Note:</strong></p>



<ol>

<li><code>0 &lt;= len(s1) &lt;= 100 </code></li>

<li><code>0 &lt;= len(s2) &lt;= 100</code></li>

</ol>




## Solutions


### Python3

```python
class Solution:
def CheckPermutation(self, s1: str, s2: str) -> bool:
return sorted(s1) == sorted(s2)
```

### Java

```java

```

### ...
```
```
50 changes: 50 additions & 0 deletions lcci/01.03.String to URL/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# [面试题 01.03. URL化](https://leetcode-cn.com/problems/string-to-url-lcci)

## 题目描述
<!-- 这里写题目描述 -->
<p>URL化。编写一种方法,将字符串中的空格全部替换为<code>%20</code>。假定该字符串尾部有足够的空间存放新增字符,并且知道字符串的&ldquo;真实&rdquo;长度。(注:用<code>Java</code>实现的话,请使用字符数组实现,以便直接在数组上操作。)</p>

<p><strong>示例1:</strong></p>

<pre><strong> 输入</strong>:&quot;Mr John Smith &quot;, 13
<strong> 输出</strong>:&quot;Mr%20John%20Smith&quot;
</pre>

<p><strong>示例2:</strong></p>

<pre><strong> 输入</strong>:&quot; &quot;, 5
<strong> 输出</strong>:&quot;%20%20%20%20%20&quot;
</pre>

<p><strong>提示:</strong></p>

<ol>
<li>字符串长度在[0, 500000]范围内。</li>
</ol>


## 解法
<!-- 这里可写通用的实现逻辑 -->


### Python3
<!-- 这里可写当前语言的特殊实现逻辑 -->

```python
class Solution:
def replaceSpaces(self, S: str, length: int) -> str:
S = S[:length] if length < len(S) else S
return S.replace(' ', '%20')
```

### Java
<!-- 这里可写当前语言的特殊实现逻辑 -->

```java

```

### ...
```
```
Loading

0 comments on commit 066e76b

Please sign in to comment.