Welcome Guest.

1Answers

c#for nesting

Asked by: William 242 views IT November 19, 2018

There are strings {start, start, start, start, end, end, end, start, start, start, end, end, end, start, start, start, end, end, start, start, start, End, end, end, end, end}, how to take the adjacent start and end, as shown in the figure, it is best to give the code

1 Answers

  1. +4Votes  

    Use a stack, press it at the beginning, and pop up when it hits it. It just happens to be a pair of

    Question: How to write the code?

    Answer: The code you want to write yourself, others can only give you an idea

    Question: Still want to ask, the relationship in the picture, to separate the relationship of each layer How to divide? That is, the first layer 1, 33, the second layer is (3, 9); (10, 15), (16, 32) the third layer (4, 8), (11, 14), (17, 22), (23,31), fourth layer (5,7) (12,13), (18,21), (24,30), layer 5 (26,27)

    Answer: The stack is distinguished. When it starts, it is pushed in. When it hits the end, it pops up. You can traverse this string once, use this stack to process it, and you can use another stack to record the position of the push or pop, so that each time When popping up, you get a pair of start and end positions

    John James- November 19, 2018 |