摘要:
func maxProfit(prices []int) int { var max = 0 for i:=1;i<len(prices);i++{ if prices[i]>prices[i-1]{//只要后一天比前一天有利可图 max += prices[i]-prices[i-1]//就在前一 阅读全文
摘要:
动态规划+sort.SearchInts() func lengthOfLIS(nums []int) int { dp := []int{} for _, num := range nums { i := sort.SearchInts(dp, num) //min_index if i == l 阅读全文
摘要:
直接遍历链表,使用set做标记位(标记是否已经到达过) /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ type void struct{} fun 阅读全文
摘要:
使用切片slice实现 type MinStack struct { stack []int minIndex int length int } /** initialize your data structure here. */ func Constructor() MinStack { ret 阅读全文
摘要:
func maxProfit(prices []int) int { // 最大利润=第i天卖出-最小买入 var min_input = prices[0]//默认第0天为最小买入 var max_profit = 0//最大利润 for i:=1;i<len(prices);i++{ min_i 阅读全文