mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
Add Chinese Translation
This commit is contained in:
parent
b2427d0e18
commit
1c9061c03a
@ -1,5 +1,8 @@
|
||||
# Palindrome Check
|
||||
|
||||
_Read this in other languages:_
|
||||
[中文](README.zh-CN.md)
|
||||
|
||||
A [Palindrome](https://en.wikipedia.org/wiki/Palindrome) is a string that reads the same forwards and backwards.
|
||||
This means that the second half of the string is the reverse of the
|
||||
first half.
|
||||
|
28
src/algorithms/string/palindrome/README.zh-CN.md
Normal file
28
src/algorithms/string/palindrome/README.zh-CN.md
Normal file
@ -0,0 +1,28 @@
|
||||
# 回文检查
|
||||
|
||||
一个[回文串](https://en.wikipedia.org/wiki/Palindrome)是一个从前访问和从后访问相同的字符串。
|
||||
这意味着字符串的后半部分与前半部分的翻转相同
|
||||
|
||||
## 例子
|
||||
|
||||
下面的是回文串 (所以将返回 `TRUE`):
|
||||
|
||||
```
|
||||
- "a"
|
||||
- "pop" -> p + o + p
|
||||
- "deed" -> de + ed
|
||||
- "kayak" -> ka + y + ak
|
||||
- "racecar" -> rac + e + car
|
||||
```
|
||||
|
||||
下面的不是回文串 (所以将返回 `FALSE`):
|
||||
|
||||
```
|
||||
- "rad"
|
||||
- "dodo"
|
||||
- "polo"
|
||||
```
|
||||
|
||||
## 参考
|
||||
|
||||
- [GeeksForGeeks - 检查一个数字是否回文](https://www.geeksforgeeks.org/check-if-a-number-is-palindrome/)
|
@ -1,5 +1,8 @@
|
||||
# Regular Expression Matching
|
||||
|
||||
_Read this in other languages:_
|
||||
[中文](README.zh-CN.md)
|
||||
|
||||
Given an input string `s` and a pattern `p`, implement regular
|
||||
expression matching with support for `.` and `*`.
|
||||
|
||||
|
@ -0,0 +1,70 @@
|
||||
# 正则表达式匹配
|
||||
|
||||
给定一个输入字符串 `s`,和一个模式 `p`,实现一个支持 `。` 和 `*` 的正则表达式匹配
|
||||
|
||||
- `。` 匹配任何单个字符。
|
||||
- `*` 匹配零个或多个前面的那一个元素。
|
||||
|
||||
匹配应该覆盖**整个**输入字符串(不是一部分)
|
||||
|
||||
**注意**
|
||||
|
||||
- `s` 可以为空或者只包含小写 `a-z`。
|
||||
- `p` 可以为空或者只包含小写 `a-z`, 以及字符`。` or `*`。
|
||||
|
||||
## 例子
|
||||
|
||||
**示例一**
|
||||
|
||||
输入:
|
||||
```
|
||||
s = 'aa'
|
||||
p = 'a'
|
||||
```
|
||||
|
||||
输出: `false`
|
||||
|
||||
解释:`a` 无法匹配 `aa` 整个字符串。
|
||||
|
||||
**示例二**
|
||||
|
||||
输入:
|
||||
```
|
||||
s = 'aa'
|
||||
p = 'a*'
|
||||
```
|
||||
|
||||
输出: `true`
|
||||
|
||||
解释:因为 `*` 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 `a`。因此,字符串 `aa` 可被视为 `a` 重复了一次。
|
||||
|
||||
**示例三**
|
||||
|
||||
输入:
|
||||
|
||||
```
|
||||
s = 'ab'
|
||||
p = '。*'
|
||||
```
|
||||
|
||||
输出: `true`
|
||||
|
||||
解释:`。*` 表示可匹配零个或多个(`*`)任意字符(`。`)。
|
||||
|
||||
**示例四**
|
||||
|
||||
输入:
|
||||
|
||||
```
|
||||
s = 'aab'
|
||||
p = 'c*a*b'
|
||||
```
|
||||
|
||||
输出: `true`
|
||||
|
||||
解释: `c` 可以重复零次, `a` 可以重复一次。 因此可以匹配 `aab`。
|
||||
|
||||
## 参考
|
||||
|
||||
- [油管](https://www。youtube。com/watch?v=l3hda49XcDE&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8&index=71&t=0s)
|
||||
- [力扣](https://leetcode-cn。com/problems/regular-expression-matching/)
|
Loading…
Reference in New Issue
Block a user