From 1c9061c03a64a5d41c3a5db3eb4b4c94ba50e343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=84=BF=E6=97=B6?= <58261676+childrentime@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:50:52 +0800 Subject: [PATCH] Add Chinese Translation --- src/algorithms/string/palindrome/README.md | 3 + .../string/palindrome/README.zh-CN.md | 28 ++++++++ .../regular-expression-matching/README.md | 3 + .../README.zh-CN.md | 70 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 src/algorithms/string/palindrome/README.zh-CN.md create mode 100644 src/algorithms/string/regular-expression-matching/README.zh-CN.md diff --git a/src/algorithms/string/palindrome/README.md b/src/algorithms/string/palindrome/README.md index 0ce77d42..a2a46fc4 100644 --- a/src/algorithms/string/palindrome/README.md +++ b/src/algorithms/string/palindrome/README.md @@ -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. diff --git a/src/algorithms/string/palindrome/README.zh-CN.md b/src/algorithms/string/palindrome/README.zh-CN.md new file mode 100644 index 00000000..a3acd993 --- /dev/null +++ b/src/algorithms/string/palindrome/README.zh-CN.md @@ -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/) \ No newline at end of file diff --git a/src/algorithms/string/regular-expression-matching/README.md b/src/algorithms/string/regular-expression-matching/README.md index e04c071e..e72df4eb 100644 --- a/src/algorithms/string/regular-expression-matching/README.md +++ b/src/algorithms/string/regular-expression-matching/README.md @@ -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 `*`. diff --git a/src/algorithms/string/regular-expression-matching/README.zh-CN.md b/src/algorithms/string/regular-expression-matching/README.zh-CN.md new file mode 100644 index 00000000..07f15e45 --- /dev/null +++ b/src/algorithms/string/regular-expression-matching/README.zh-CN.md @@ -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/)