上一页 1 2 3 4 5 6 7 8 9 ··· 59 下一页
摘要: 零钱兑换一:求兑换最少硬币数 https://leetcode.cn/problems/coin-change/ func coinChange(coins []int, amount int) int { dp:=make([]int,amount+1) //dp[i]标识金额为i的时候,需要的最 阅读全文
posted @ 2022-06-27 14:25 知道了呀~ 阅读(222) 评论(0) 推荐(0)
摘要: 最多包含k个字符类型的子串 注意的是,k标识字符类型,不是次数 func findStr(s string,k int)int{ mxAns:=0 sLen:=len(s) if sLen<=k{ return sLen } mp :=make(map[byte]int) le:=0;ri:=0 / 阅读全文
posted @ 2022-06-26 19:19 知道了呀~ 阅读(219) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/ZL6zAn/ var n,m,ans int var dir =[][]int{{1,0},{0,1},{-1,0},{0,-1}} func checkRange(x,y int) bool{ if x>=0&&x<n&&y>=0&&y< 阅读全文
posted @ 2022-06-26 18:00 知道了呀~ 阅读(68) 评论(0) 推荐(0)
摘要: func deleteDuplicates( head *ListNode ) *ListNode { new := &ListNode{Next:head} pre,cur := new,head for cur != nil{ for cur.Next != nil && cur.Val == 阅读全文
posted @ 2022-06-26 17:27 知道了呀~ 阅读(79) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/search-in-rotated-sorted-array/ 解题思路: 1、数组旋转之后,分成了两个递增区间,所以第一个步骤就是确定mid位置在那个区间里面 2、在比较mid和target的大小,确定target在区间的左边还是右边 3、 阅读全文
posted @ 2022-06-25 23:00 知道了呀~ 阅读(96) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/merge-intervals/ func merge(intervals [][]int) [][]int { sort.Slice(intervals, func(i, j int) bool { return intervals[i][ 阅读全文
posted @ 2022-06-25 16:11 知道了呀~ 阅读(77) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-06-23 20:10 知道了呀~ 阅读(67) 评论(0) 推荐(0)
摘要: func trailingZeroes(n int) int { ans:=0 for n!=0{ n=n/5 ans=ans+n } return ans } 阅读全文
posted @ 2022-06-22 11:27 知道了呀~ 阅读(79) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/longest-substring-without-repeating-characters/ func lengthOfLongestSubstring(s string) int { mp:=make(map[string]int) le 阅读全文
posted @ 2022-06-22 11:18 知道了呀~ 阅读(73) 评论(0) 推荐(0)
摘要: 题目连接:https://leetcode.cn/problems/sort-list/ 快排(使用快排容易超时,建议使用归并排序) func main(){ head:=&ListNode{} end:=head aaa:=0 for i:=0;i<6;i++{ if i%2==0{ aaa=i 阅读全文
posted @ 2022-06-21 22:31 知道了呀~ 阅读(147) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 59 下一页