Shanghai pioneer shangtai interview questions

Source: Internet
Author: User

Go SubProgram. When the white child enclose the sunspots, the sunspots will be taken away.
InAlgorithmIdea: a two-dimensional array qipan [] [] is used to represent the chess piece. 0 indicates null, 1 indicates white, and 2 indicates sunspots; A two-dimensional array flag [] [] is used to represent the flag of row I. The flag [] [] is initialized as 0 for the pawns in column J. From left to right, from top to bottom, when qipan [I] [J] = 2, if the front and back of qipan are both white, then the flag [I] [J] = Flag [I] [J] + 1; if it has a white child on the left and a black child on the top, then flag [I] [J] = Flag [I] [J-1]; if it has a sunspot on the left, when it is white, then flag [I] [J] = Flag [I-1] [J]; if it is black above and left, then flag [I] [J] = min (flag [I-1] [J], flag [I] [J]). then, we traverse qipan from right to left and from bottom to top. The principle is similar to above. When flag [I] [J] is 2, qipan [I] [J] = 0; // subquery.

Go subprogram:
It is obvious that the return method is used for analysis. When you move down, you can check the surrounding pawns associated with the pawns or when they are surrounded. (No need to traverse from scratch)
For example, the white sub is connected to two white sub, and the white sub is connected to four white sub... In this way, the system traverses the past. If it doesn't get through, it goes back to the system and continues the traversal. When the loop is formed, it eats the sunspots.

Java_web (continuously crawling up) algorithms are acceptable, but it is not considered that a person like fuzhu kills himself. You did not consider it. You only consider the situation when killing the other party.

 

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.