My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.
now that4Two times,3也Two times,So it means that this question is nothing more than“As much as possible2indivual2indivual取,Turn count+1” Although it can be optimized at running time,But I prefer to write a line
Code:
1 2 3
classSolution: defminCount(self, coins: List[int]) -> int: returnsum(i // 2 + i % 2for i in coins)