topic:
1237. Find out the positive combination of the given square.md
Thought:
Want to be complicated,It turned out to be intended to recover,Then constantly find out the solution。Then Ling Shen tells us:In fact, this question is a double pointer,One on the far left is on the right。
Monoly increase function,XCan only increase,YCan only reduce,So iff(x,y)<z,ExplainXIt’s time to increase,vice versa。
Because you need to continue to find after equal,So continue f(x,y)<zTalent operation,After modificationf(x+1,y)>f(x,y)=z,Depending on the circumstances 2,Can y minus one。
Code:
1 | class Solution: |
1 |