Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1924692

Browse files
Update README.md
1 parent 0b5cd1d commit 1924692

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LeetCode 是一个非常棒的 OJ(Online Judge)平台,收集了许多公
3333

3434
> Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()", which has length = 2. Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4.
3535
36-
```
36+
```C#
3737
//栈的典型应用
3838
//能想到栈,但是能想到Push字符索引,真的不是很容易(这道题一般的想法是存储‘(’ ‘)’这些符号)
3939
public int LongestValidParentheses(string s)
@@ -70,6 +70,7 @@ LeetCode 是一个非常棒的 OJ(Online Judge)平台,收集了许多公
7070
return longest;
7171
}
7272
```
73+
7374
|ID|Tags|Solution|
7475
|--|----|--------|
7576
|3|String;|[Longest Substring Without Repeating Characters](http://blog.csdn.net/daigualu/article/details/73105674)|
@@ -194,7 +195,7 @@ return heapq.nlargest(k, num_count, key=lambda x: num_count[x])
194195

195196
而用 C++ 实现的话,代码会多很多,带来的好处就是速度的飞跃。具体代码在 这里 ,建立大小为 k 的小顶堆,每次进堆时和堆顶进行比较,核心代码如下:
196197

197-
```
198+
```c++
198199
// Build the min-heap with size k.
199200
for(auto it = num_count.begin(); it != num_count.end(); it++){
200201
if(frequent_heap.size() < k){
@@ -213,7 +214,7 @@ for(auto it = num_count.begin(); it != num_count.end(); it++){
213214

214215
如果用 C++ 的话,相信很多人也能避开求中间值的整型溢出的坑: int mid = low + (high - low) / 2; ,于是写出下面的代码:
215216

216-
```
217+
```c++
217218
int low = 0, high = x;
218219
while(low <= high){
219220
// int mid = (low+high) / 2, may overflow.
@@ -228,7 +229,7 @@ while(low <= high){
228229

229230
除了臭名昭著的整型溢出问题,c++ 和 python 在位运算上也有着一点不同。以 371 Sum of Two Integers 为例,不用 +, - 实现 int 型的加法 int getSum(int a, int b) 。其实就是模拟计算机内部加法的实现,很明显是一个位运算的问题,c++实现起来比较简单,如下:
230231

231-
```
232+
```c++
232233
int getSum(int a, int b) {
233234
if(b==0){
234235
return a;
@@ -270,7 +271,7 @@ StefanPochmann 也不厌其烦地给出了自己的答案:
270271
<center>
271272
![这里写图片描述](http://img.blog.csdn.net/20170610204936185?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZGFpZ3VhbHU=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
272273
273-
<h4>已完成题目列表</h4>
274+
## 已完成题目列表
274275
|ID|Tags|Solution|
275276
|--|----|--------|
276277
|1|Array;HashTable;|[Two Sum](http://blog.csdn.net/daigualu/article/details/68957096)|

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /