分享到plurk 分享到twitter 分享到facebook

版本 ec2567bfe63e17dfb9e0084a969e71157e5f5380

acm/course/LCS

Changes from ec2567bfe63e17dfb9e0084a969e71157e5f5380 to 3c795432399a23f7497a27b20c78e2c920ad5f5c

Define
========
<ul> Find a **`sub-sequence`** of 2 given sequences in which the sub-sequence's elements are appear in both original sequences
     and the sub-sequence is **`as long as possible.`** </ul>
<ul> ex: 'aabbcc', 'abbccc' => 'abc'</ul>
<br/>

##What do we want to know?
<ul> – The LCS of S1[1...i] and S2[1...j]. </ul>
<ul> – i.e. LCS[i][j] </ul><br/>

##How can we get that?
<ul>– Find the previous number with longest LIS. </ul>
<ul>– LCS[i][j]:
 <ul>```c++
     0                            , i=0 or j=0
     LCS[i-1][j-1]+1              , S1[i]=S2[j]
     max(LCS[i-1][j],LCS[i][j-1]) , S1[i]≠S2[j]
```
 </ul>
</ul>
<ul>
ex: 'CBABCABCC' , 'ABCABCBA' => ABCABC<br/>
ex: 'CBABCABCC' , 'ABCABCBA' => 'ABCABC'<br/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-1.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-2.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-3.png" height="200" width="200"/>
 <img src="http://wiki.csie.ncku.edu.tw/acm/LCS-4.png" height="200" width="200"/>
</ul>