llllmz

导航

2024年2月22日

11. 盛最多水的容器C++

摘要: 原本想o(n2)遍历的,结果超时了,果然没这么简单就解决。 class Solution { public: int s(vector<int> height,int i,int j){ int s1=min(height[i],height[j])*(j-i); return s1; } int 阅读全文

posted @ 2024-02-22 20:59 神奇的萝卜丝 阅读(19) 评论(0) 推荐(0)

283. 移动零C

摘要: 类似像一个筛选过程,如果非0就加入数组,不非0就不加。 void moveZeroes(int* nums, int numsSize) { int x=0,y=0; while(x<numsSize){ if(y>=numsSize) break; if(nums[y]!=0){ nums[x]= 阅读全文

posted @ 2024-02-22 20:31 神奇的萝卜丝 阅读(13) 评论(0) 推荐(0)