Q3-Summary of questions beyond the school gate

Source: Internet
Author: User

The serial number for this question is 2808.

I got a question before I got off work last night and drew a picture on the paper with a pen.

 

The same method in Q2 is used to store input data, but the array format is int;

As long as you know the start and end locations of the subway station, the cut-down tree is end-begin + 1;

The remaining tree is the total number of trees (L + 1)-cut tree

 

The difficulty lies in how to calculate the overlapping area of the subway. When I think of the method used in Q2 to list all the situations, I will be stranded until this morning.

This morning, I drew a lot of images on paper, and formed an animation in my head. I moved the starting and ending positions of the New Earth iron to summarize the situation. I tried it twice and made another interval, die.

Considering range union, there is no upper limit on storage, and it is attempted

 

If there is a way, I read the text in the book, maybe it is too tangled, just read a word to instantly epiphany:

Array ElementThe value in represents each tree.MarkIt is false (0), and is still marked as true (1). It is true (1) at first );

At last, you only need to count the number of all element values in the array as 1, that is, the remaining tree.

How can I be so smart ~, Bunker,

I gave up my previous idea of seeking for a range and adopted this processing method. Soon I finished writing and submitted it successfully.

 

In addition, the previous improvement is that the first step is to consider how to handle user input errors (for example, the input range exceeds the start l ).

The question preparation time is also shortened.

Comrade P continues his efforts and strives to become a master of the mind as soon as possible if he encounters problems without looking at the explanation or Google.

1 accepted

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.