Skip to content

feat: update cpp solution to leetcode problem: No.0026,No.0080 #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert "feat: add python and java solutions to leetcode problem: No.1…
…507"

This reverts commit e62eb43.
  • Loading branch information
gqjia committed Apr 6, 2021
commit ae9abcd384c259cb4c9aa72f6b61e39a46dc2092
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@

## 维护者

[Yang Libin](https://github.com/yanglbme): GitHub / Gitee 技术社区 @Doocs 创建者;开源组织 [@TheAlgorithms](https://github.com/TheAlgorithms) 核心成员之一
[Yang Libin](https://github.com/yanglbme): GitHub / Gitee 技术社区 @Doocs 创建者;[@TheAlgorithms](https://github.com/TheAlgorithms) 组织成员

## 加入我们

刷编程题的最大好处就是可以锻炼解决问题的思维能力。相信我,「如何去思考」​ 本身也是一项需要不断学习和练习的技能。非常感谢前微软工程师、现蚂蚁金服技术专家 [@kfstorm](https://github.com/kfstorm) 贡献了本项目的所有 [C# 题解](https://github.com/doocs/leetcode/pull/245)。

如果你对本项目感兴趣,并且希望加入我们刷题大军,欢迎随时提交 [PR](https://github.com/doocs/leetcode/pulls)。请参考如下步骤:

1. 将本项目 fork 到你的个人 GitHub / Gitee 帐户,然后 clone 到你的本地机器;
1. 对项目做出一些变更,然后使用 git addcommitpush 等命令将你的变更提交到你的远程 GitHub / Gitee 仓库;
1. 将本项目 <kbd>fork</kbd> 到你的个人 GitHub / Gitee 帐户,然后 <kbd>clone</kbd> 到你的本地机器;
1. 对项目做出一些变更,然后使用 git <kbd>add</kbd>、<kbd>commit</kbd>、<kbd>push</kbd> 等命令将你的变更提交到你的远程 GitHub / Gitee 仓库;
1. 将你的变更以 PR 的形式提交过来,项目的维护人员会在第一时间对你的变更进行 review!
1. 你也可以参考帮助文档「[GitHub](https://help.github.com/cn) / [Gitee](https://gitee.com/help)」了解更多细节。

Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ Complete solutions to [LeetCode](https://leetcode-cn.com/problemset/all/), [LCOF

I'm looking for long-term contributors/partners to this repo! Send me [PRs](https://github.com/doocs/leetcode/pulls) if you're interested! See the following:

1. Fork [this repository](https://github.com/doocs/leetcode) to your own GitHub account and then clone it to your local machine.
1. Make some changes to your leetcode repository, then push the changes to your remote GitHub repository.
1. <kbd>Fork</kbd> [this repository](https://github.com/doocs/leetcode) to your own GitHub account and then <kbd>clone</kbd> it to your local machine.
1. Make some changes to your leetcode repository, then <kbd>add</kbd>, <kbd>commit</kbd> and <kbd>push</kbd> the changes to your remote GitHub repository.
1. Create a pull request with your changes!
1. See [CONTRIBUTING](https://github.com/doocs/.github/blob/main/CONTRIBUTING.md) or [GitHub Help](https://help.github.com/en) for more details.

Expand Down
27 changes: 2 additions & 25 deletions solution/1500-1599/1507.Reformat Date/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,22 @@

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

切分 `date` 字符串,获取对应的 `year`, `month`, `day`,然后拼接起来即可。

<!-- tabs:start -->

### **Python3**

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

```python
class Solution:
def reformatDate(self, date: str) -> str:
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
mapper = {v: str(k + 1) for k, v in enumerate(months)}
split = date.split(' ')
year = split[2]
month = mapper.get(split[1])
day = split[0][:len(split[0]) - 2]
return year + '-' + month.zfill(2) + '-' + day.zfill(2)

```

### **Java**

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

```java
class Solution {
public String reformatDate(String date) {
Map<String, Integer> mapper = new HashMap<>();
String[] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
for (int i = 0; i < months.length; ++i) {
mapper.put(months[i], i + 1);
}
String[] split = date.split(" ");
int year = Integer.parseInt(split[2]);
int month = mapper.get(split[1]);
int day = Integer.parseInt(split[0].substring(0, split[0].length() -2));
return String.format("%d-%02d-%02d", year, month, day);
}
}

```

### **...**
Expand Down
25 changes: 2 additions & 23 deletions solution/1500-1599/1507.Reformat Date/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,13 @@
### **Python3**

```python
class Solution:
def reformatDate(self, date: str) -> str:
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
mapper = {v: str(k + 1) for k, v in enumerate(months)}
split = date.split(' ')
year = split[2]
month = mapper.get(split[1])
day = split[0][:len(split[0]) - 2]
return year + '-' + month.zfill(2) + '-' + day.zfill(2)

```

### **Java**

```java
class Solution {
public String reformatDate(String date) {
Map<String, Integer> mapper = new HashMap<>();
String[] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
for (int i = 0; i < months.length; ++i) {
mapper.put(months[i], i + 1);
}
String[] split = date.split(" ");
int year = Integer.parseInt(split[2]);
int month = mapper.get(split[1]);
int day = Integer.parseInt(split[0].substring(0, split[0].length() -2));
return String.format("%d-%02d-%02d", year, month, day);
}
}

```

### **...**
Expand Down
14 changes: 0 additions & 14 deletions solution/1500-1599/1507.Reformat Date/Solution.java

This file was deleted.

9 changes: 0 additions & 9 deletions solution/1500-1599/1507.Reformat Date/Solution.py

This file was deleted.