自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(4)
  • 收藏
  • 关注

原创 LeetCode219:存在重复 II

迭代,这个题目写的怪怪的class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { for(int i=0;i<nums.length-1;i++) { for(int j=i+1;j<nums.length;j++) if(nums[i]==nums[j...

2018-04-21 17:11:28 264

原创 LeetCode122:买卖股票的最佳时机 II(动态规划)

动态规划:1.class Solution { public int maxProfit(int[] prices) { int[] profit = new int[prices.length]; if(prices.length==0) return 0; for (int i = 0; i < prices.length; i++) ...

2018-04-21 16:38:57 1133

原创 LeetCode121:买卖股票的最佳时机

class Solution { public int maxProfit(int[] prices) { int max=0; int count=0; if(prices.length<=1) return 0; for(int i=0;i<prices.length-1;...

2018-04-20 16:38:07 291

原创 最大子序和

之前在博客搜到的算法复杂度为O(N)的最大子序和并没有考虑到都为负数的情况,因此改进为如下算法public class MaxSubArray53 { public static void main(String[] args) { int[] nums = { 4, 1, -3, 4, 1, 2, 1, 1, 4 }; int sum=0; int maxSum=-21474836...

2018-04-20 16:23:25 220

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除