Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Nov 8, 2018
1 parent fab2f36 commit 0c6f6ea
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions Hash/930.Binary-Subarrays-With-Sum/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,3 @@
我们用Map[k]表示,数组A前缀恰好有k个1的位置,其之后会紧跟着有多少个0.

假设遍历到j位置,累计有count个1,那么我们需要定位到前缀累计有count-S个1的位置,其之后有多少个紧跟着的0,比如说有M个,就说明起点i有多少M+1个方案.这里注意,如果没有紧跟着的0,也算是一种方案.

构造这个预处理字典的代码是:
```cpp
int count = 0;
int result = 0;
Map[0] = 1;
for (int i=0; i<A.size(); i++)
{
count+=A[i];
result+=Map[count-S]; //注意,先做这一步操作.
Map[count]++;
}
return result;
```

0 comments on commit 0c6f6ea

Please sign in to comment.