1. 首页
  2. 主题
  3. Go问与答

求助,leetcode的问题?

qiuquanwu · · 1370 次点击
https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/1/array/21/ 请大家用go解决一下这个问题。
```golang func removeDuplicates(nums []int) int { p:=0 ct:=0 idx:=0 for i,v:=range nums { if i==0 { p = v ct = ct + 1 idx = idx + 1 continue } if v!=p { nums[idx]=v ct = ct +1 p = v idx = idx + 1 } } return ct } ```
#1
更多评论
这里有中文版本的解析,可以看看,希望能帮到你:https://cloud.tencent.com/developer/doc/1101
#2
你有3个变量,那就是O(3)了吧
#3

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中