avatar
Siz Long

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 me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

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 me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

PythonCoincidence,Random algorithmO(nlogn)Push

  2024-01-01        
字数统计: 140字   |   阅读时长: 1min

Course:

  1. 看了官方answer,Similar to my first approach,AllsortedLater in the new listappend。But I think I can’t prove the correctness,Because it is Zhou Sai dare not submit at will。
  2. Discover when thinking about the first solution,If I keepfor i in Whole array,Determine whether to meet the conditions and then exchange the position,What should I do if I enter the dead cycle??If a special case fails every time, it needs to be exchanged. What is the difference between random disruption??
  3. After watching the solution of other big guys,I am still too young
1
2
3
4
5
6
7
8
9
10
def rearrangeArray(self, nums: List[int]) -> List[int]:
i = 1
while i < len(nums)-1:
if nums[i] == (nums[i - 1] + nums[i + 1]) // 2:
random.shuffle(nums)
i = 1
else:
i += 1
else:
return nums
  • Python
  • solved,answer

扫一扫,分享到微信

微信分享二维码
1819.Different numbers in the sequence
19.Delete the countdown of the linked listNNode
目录
ahoh, this article has no catalog.

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号