![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
sdusgq
这个作者很懒,什么都没留下…
展开
-
leetcode605
sgq‘s answer:class Solution { public boolean canPlaceFlowers(int[] flowerbed, int n) { int i = 0; int num = 0; // 找1法 while(i < flowerbed.length){ // 找flowerbed[i] == 1的点 if(flowerbed[i] == 1){原创 2021-02-24 21:26:39 · 77 阅读 · 0 评论 -
leetcode219
枚举法:class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { for (int i = 0; i < nums.length; i++) { for (int j = i+1; j <= Integer.min(nums.length - 1, i + k); j++) { if(nums[i] == nums[j]原创 2021-02-22 19:57:04 · 59 阅读 · 0 评论 -
leetcode1588
//以{1,2,3,4,5}为例,计算i为某确定值时候对应arr[i]出现的总次数。public int sumOddLengthSubarrays(int[] arr) { int sum = 0; int len = arr.length; for (int i = 0; i < arr.length; i++) { //当i = 2时候,arr[2] = 3,左边有2个元素1,2, //需要保证连续,则取元素方式如下: /原创 2021-02-22 15:17:38 · 66 阅读 · 0 评论