![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
leetcode-myself
practice structure and algorithm
sky527759
这个作者很懒,什么都没留下…
展开
-
124. binary-tree-maximum-path-sum, golang
description: 124. Binary Tree Maximum Path Sum Hard 7460 460 Add to List Share A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most原创 2021-10-31 12:00:03 · 108 阅读 · 0 评论 -
160. Intersection of Two Linked Lists, C++
description: https://leetcode.com/problems/intersection-of-two-linked-lists/ code.1: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Soluti原创 2020-06-15 11:08:54 · 106 阅读 · 0 评论 -
191. number-of-1-bits, golang
description: 191. Number of 1 Bits Easy 649 478 Add to List Share Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example...原创 2020-03-15 13:32:24 · 142 阅读 · 0 评论 -
190. reverse-bits, golang
description: 190. Reverse Bits Easy 821 306 Add to List Share Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 Output: 001110010111100000101001010...原创 2020-03-15 13:21:19 · 129 阅读 · 0 评论 -
7. reverse-integer, golang
description: 7. Reverse Integer Easy 2949 4654 Add to List Share Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 ...原创 2020-03-15 10:12:15 · 149 阅读 · 0 评论 -
17. letter-combinations-of-a-phone-number, golang
description: 17. Letter Combinations of a Phone Number Medium 2969 357 Add to List Share Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number ...原创 2020-01-20 19:33:50 · 205 阅读 · 0 评论 -
260. single-number-iii, golang
description: 260. Single Number III Medium 1088 86 Add to List Share Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. ...原创 2019-12-30 13:29:55 · 98 阅读 · 0 评论 -
268. missing-number, golang
description: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output: 2 Example 2: Input: [9,6,4,2,3,5...原创 2019-12-28 17:10:36 · 94 阅读 · 0 评论 -
137. single-number-ii, golang
description: Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtim...原创 2019-12-28 16:54:29 · 125 阅读 · 0 评论 -
136. single-number, golang
description: Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement ...原创 2019-12-28 11:54:29 · 92 阅读 · 0 评论 -
279. perfect-squares, golang
code: func numSquares(n int) int { if n <= 0 { return 0 } //refer to Lagrange's Four-square Theorem, thk for Euler //if n % 4 == 0 then it can be divide by 4 f...原创 2019-12-02 18:06:30 · 114 阅读 · 0 评论 -
138. copy-list-with-random-pointer, C++
code: /* // Definition for a Node. class Node { public: int val; Node* next; Node* random; Node() {} Node(int _val, Node* _next, Node* _random) { val = _val; next...原创 2019-11-29 13:32:06 · 116 阅读 · 0 评论 -
19. remove-nth-node-from-end-of-list, golang
code: /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeNthFromEnd(head *ListNode, n int) *ListNode { i, listRet, temp1 :...原创 2019-11-26 22:45:42 · 112 阅读 · 0 评论 -
21. merge-two-sorted-lists, golang
code: /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode { if nil == l1 { ...原创 2019-11-26 08:55:25 · 123 阅读 · 0 评论 -
41. first-missing-positive, golang
code: func firstMissingPositive(nums []int) int { nLen := len(nums) if 0 == nLen { return 1 } for i, _ := range nums { for nums[i] != i + 1 && nums[i]...原创 2019-11-18 12:56:56 · 116 阅读 · 0 评论 -
15. 3Sum, golang
code: func threeSum(nums []int) [][]int { nLen := len(nums) if nLen < 3 { return nil } var anRet [][]int //fmt.Printf("anRet:%p, %v, Len:%d, Cap:%d\n", anRet, anRet...原创 2019-11-14 22:52:30 · 138 阅读 · 0 评论 -
9. palindrome-number, golang
code: func isPalindrome(x int) bool { if x < 0 { return false } else if x < 10 { return true } else { //get The number of digits of the integer //2^64...原创 2019-11-07 13:33:35 · 102 阅读 · 0 评论 -
5. longest-palindromic-substring, golang
code: func longestPalindrome(s string) string { nLen := len(s) if 0 == nLen { return "" } /*with no thought of those characters that have many bytes, solve this probl...原创 2019-11-05 23:36:26 · 167 阅读 · 0 评论 -
4. median-of-two-sorted-arrays, golang
code: func findMedianSortedArrays(nums1 []int, nums2 []int) float64 { /*from question : You may assume nums1 and nums2 cannot be both empty. */ /*assume nums1 and nums2 are both in order */ //e...原创 2019-11-01 09:26:40 · 151 阅读 · 0 评论 -
3.longest-substring-without-repeating-characters, golang
code: func lengthOfLongestSubstring(s string) int { if “” == s { return 0 } /*from internet, it should have 256 different characters. with no thought of those characters that have many bytes. */ var ...原创 2019-10-21 18:06:25 · 134 阅读 · 0 评论 -
2.add-two-numbers, golang
code: /** Definition for singly-linked list. type ListNode struct { Val int Next *ListNode } */ func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode { if nil == l1 { return l2 } else i...原创 2019-10-17 09:42:50 · 163 阅读 · 0 评论 -
1.two-sum, golang
code: type KeyValue struct { Key int Value int } type ArrKV []KeyValue func (kvs ArrKV) Len() int { return len(kvs) } func (kvs ArrKV) Less(i, j int) bool { return kvs[i].Value < kvs[j].Valu...原创 2019-10-16 12:46:50 · 158 阅读 · 0 评论