{Csdn} {}

Source: Internet
Author: User

Ideas:

Given a string, two non-overlapping strings are obtained. They flip and complement each other. One of the strings can be the original string substrings that can be deleted up to two characters.

Due to the ability to delete sub-strings in dynamic planning, I first thought of the LCS problem, but I need to enumerate all the lengths. The complexity is O (n ^ 3) and cannot be obtained.

Due to the linear increase in length, the length of binary search is considered. The complexity is O (n ^ 2 * log (n )).

You need to search twice to find that the length of the substring (LN) is equal to the length of the LCS of the substring (LN + k) to be searched. Then, the corresponding substrings complement each other, k indicates the number of characters deleted, and the question is 2.

In this case, the complexity is irrelevant to K. However, this method has never been AC, and you need to correct it if it is correct or not.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.