自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Leetcode53最大子序和 动态规划和分治法双解法

1.动态规划这是这道题想起来最容易的做法,建立前缀和数组,每一个元素表示对应nums数组此元素作为结尾的子序和class Solution {public: int maxSubArray(vector<int>& nums) { vector<int> dp(nums.size(),0); int maxn=nums[0]; if(nums.size()==1){ return nu

2020-09-24 21:21:50 195

原创 Leetcode 42.接雨水 两种解法

解法1:栈(一次遍历)stk存储比当前高度更低或相等的高度 cur代表当前高度之前的最低点(stk.pop) cur高度上储水量为cur*min(stk.top,height[i]) 判断是否会在边上,留不住水(cur,stk.empty()) stk.empty(),入栈class Solution {public: int trap(vector<int>& height) { int i,j,t,h,sum=0,cur; stack&lt

2020-09-11 13:00:22 96

原创 Leetcode25.K 个一组翻转链表

经典dummyhead题目每隔n个节点建立一个dummyhead,使用头插法进行连接以倒置顺序,后连接在前段的后面#include<iostream>#include<vector>using namespace std;struct ListNode{ int val; ListNode *next; ListNode() : val(0), next(NULL) {} ListNode(int x) : val(x), nex.

2020-09-10 13:22:28 92

原创 leetcode寻找两个正序数组的中位数

双指针快乐解决#include <stdio.h>#include <string.h>#include <stdlib.h>#define maxn 100double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size){ int *a,i,j,k; double r; a=(int *)malloc(sizeof(int)*(nums1Size+num

2020-05-21 18:08:35 147

原创 Leetcode3无重复字符的最长子串,纯c

Leetcode3无重复字符的最长子串动态规划dp[i]=dp[i-1]+1;i字符未出现过或是前一个相同字符的距离超过了以前一个字符为结尾的字符串的长度dp[i]=i-a[t];与其哪一个相同字符的距离较近#include <stdio.h>#include <string.h>#include <stdlib.h>#define maxn 200int lengthOfLongestSubstring(char * s){ int t,index=

2020-05-21 14:11:17 101

空空如也

空空如也

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

TA关注的人

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