leetcode
胡大佬
这个作者很懒,什么都没留下…
展开
-
leetcode #128Longest Consecutive Sequence
#128Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4, 200, 1, 3, 2]Output: 4Expla...原创 2018-05-04 12:05:42 · 132 阅读 · 0 评论 -
leetcode #203. Remove Linked List Elements
description:Remove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5Solution:# Definition for singly-linked list.# cla原创 2018-04-30 08:52:32 · 93 阅读 · 0 评论 -
leetcode #66 Plus one
descripion:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each原创 2018-04-30 08:33:16 · 289 阅读 · 0 评论 -
leetcode #120 Triangle
# description: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4...原创 2018-04-30 08:14:20 · 103 阅读 · 0 评论 -
LeetCode #56 Merge Intervals
题目链接:https://leetcode.com/problems/merge-intervals/思路:排序后,遍历一遍数组操作import "sort"type myvalue2 [][]intfunc (p myvalue2) Len() int { return len(p)}func (p myvalue2) Less(i, j int) bool { i...原创 2019-07-09 08:41:04 · 174 阅读 · 0 评论 -
leetcode #1 Two Sum
解决方法:直接两次循环,两数相加为target则return,时间复杂度 O(n2n^2n2)func twoSum(nums []int, target int) []int { for ai, a:=range nums{ for bi, b:=range nums[ai+1:]{ if a+b == target{ ...原创 2019-07-05 08:43:24 · 125 阅读 · 0 评论 -
leetcode#179 Largest Number
将整数转换为字符串,然后排序即可(需自定义排序规则为:s1 + s2 > s2 + s1)import "strconv"type newType []stringfunc (p newType) Len() int { return len(p)}// 排序规则func (p newType) Less(i, j int) bool { return p[i]...原创 2019-07-10 23:32:11 · 149 阅读 · 0 评论