A girl and a robot thinking together

Think together · First, a short story

The girl needs to find the largest number in a sequence. The robot walks through the whole solving process instead of jumping straight to code.

Lay out the process

Follow the numbered steps, then explain them in your own words.
  1. Read the taskA non-empty integer sequence
  2. Choose an approachStart with the first value, then compare each one
  3. ImplementUpdate when a larger value appears
  4. VerifyNegatives, duplicates, one element

A complete solution moves from understanding the task to an algorithm, implementation, and verification.

This maximum-finding method keeps the largest value seen so far, so after examining every item it holds the overall maximum. Understanding why matters more than just seeing the answer.

01What does AC mean?

AC (Accepted) means the program passed the tests prepared for that problem by the online judge and was judged correct.

But the goal of learning is not just to see a green AC; it is to know why your solution earned it.

02Stage 1: understand the problem

① Read the statement② Identify input and output③ Check constraints④ Work through a small example

Do not rush into implementation at this stage.

03Stage 2: build a model

Translate the story into:

  • Variables
  • Arrays
  • States
  • Trees or graphs
  • Mathematical relationships

Determine which information actually affects the answer.

04Stage 3: find a correct approach

If you cannot see an efficient idea yet, first design a brute-force solution.

Get a correct solution→Find repetition and bottlenecks→Then optimize

05Stage 4: check complexity

Use the maximum input size to reason about the cost:

  • How many times will the loops run?
  • How many states may the search visit?
  • How much memory will it use?

06Stage 5: write the code

Keep the implementation clear:

Clear names

Express what values mean.

Explicit boundaries

Use correct array and loop ranges.

Adequate types

Avoid integer overflow.

Clear structure

Split work into functions when useful.

07Stage 6: test it yourself

At a minimum, test:

  • The official samples
  • The smallest input
  • The largest or nearly largest input
  • Special orders and duplicate values
  • A small example you worked out by hand

08Stage 7: what if you get WA?

WA (Wrong Answer) does not mean “change things randomly and try again.”

Find a failing case→Trace the first wrong step→Fix it and run regression tests

09What should you really take away?

What have you learned?

  • AC means the program passed the judge's tests.
  • Solving a problem is more than writing code.
  • Understand and model the task before designing an approach.
  • Moving from brute force to optimization is an important path.
  • Complexity, boundaries, testing, and debugging are all part of problem solving.
  • The real goal is to develop a reliable, reusable way to solve problems.

Topic complete: The foundational “Programming and Algorithms” learning path is now connected from start to finish.

Your turn to try

The maximum appears twice, and you need the earliest position. Should you replace the answer when the values are equal?

Ready? Open the explanation

No. Updating only when a value is strictly larger preserves the first position. Follow the problem's indexing convention as well.