Method 2: As shown below.
The solution of the original function of this question exceeds the requirements of the new curriculum standard