![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode 1401 - 1500
nb20102010
这个作者很懒,什么都没留下…
展开
-
[LeetCode][Go] LeetCode 1405. Longest Happy String
func longestDiverseString(a int, b int, c int) string { if a >= b && a >= c { return helper("a", "b", "c", a, b, c) } else if b >= a && b >= c { return helper("b", "a", "c", b, a, c) } else {原创 2020-05-19 14:52:46 · 171 阅读 · 0 评论 -
[LeetCode][Go] LeetCode 1404. Number of Steps to Reduce a Number in Binary Representation to One
func numSteps(s string) int { cnt, carrier := 0, 0 for i := len(s) - 1; i > 0; i -= 1 { if s[i] == '0' && carrier == 0 { cnt += 1 } else if s[i] == '1' && carrier == 1 { cnt += 1原创 2020-05-14 09:51:58 · 137 阅读 · 0 评论 -
[LeetCode][Go] LeetCode 1403. Minimum Subsequence in Non-Increasing Order
func minSubsequence(nums []int) []int { sum, sum2 := 0, 0 for _, n := range nums { sum += n } sort.Slice(nums, func(a, b int) bool {return nums[b] < nums[a]}) i := 0 for i < len(nums) && sum2 <= su原创 2020-05-12 11:25:55 · 163 阅读 · 0 评论 -
[LeetCode][Go] Leetcode 1402. Reducing Dishes
func maxSatisfaction(s []int) int { sort.Ints(s) sum := 0 max := 0 total := 0 for i := len(s) - 1; i >= 0; i-- { sum += s[i] total += sum if(total > max){ max = total } else {原创 2020-05-11 12:29:08 · 141 阅读 · 0 评论 -
[LeetCode][Go] Leetcode 1401. Circle and Rectangle Overlapping
func checkOverlap(r, x, y, x1, y1, x2, y2 int) bool { if x >= x1 && x <= x2 && y >= y1 && y <= y2 { return true } else if x >= x1 && x <= x2 && (y < y1 || y > y2) { if原创 2020-05-10 15:33:52 · 207 阅读 · 0 评论