leetcode-myself
practice structure and algorithm
sky527759
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
124. binary-tree-maximum-path-sum, golang
description:124. Binary Tree Maximum Path SumHard7460460Add to ListShareA 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 · 176 阅读 · 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 · 148 阅读 · 0 评论 -
191. number-of-1-bits, golang
description:191. Number of 1 BitsEasy649478Add to ListShareWrite 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 · 192 阅读 · 0 评论 -
190. reverse-bits, golang
description:190. Reverse BitsEasy821306Add to ListShareReverse bits of a given 32 bits unsigned integer.Example 1:Input: 00000010100101000001111010011100Output: 001110010111100000101001010...原创 2020-03-15 13:21:19 · 173 阅读 · 0 评论 -
7. reverse-integer, golang
description:7. Reverse IntegerEasy29494654Add to ListShareGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321...原创 2020-03-15 10:12:15 · 202 阅读 · 0 评论 -
17. letter-combinations-of-a-phone-number, golang
description:17. Letter Combinations of a Phone NumberMedium2969357Add to ListShareGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number ...原创 2020-01-20 19:33:50 · 281 阅读 · 0 评论 -
260. single-number-iii, golang
description:260. Single Number IIIMedium108886Add to ListShareGiven 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 · 136 阅读 · 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: 2Example 2:Input: [9,6,4,2,3,5...原创 2019-12-28 17:10:36 · 148 阅读 · 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 · 165 阅读 · 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 · 134 阅读 · 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 · 154 阅读 · 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 · 166 阅读 · 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 · 156 阅读 · 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 · 174 阅读 · 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 · 143 阅读 · 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 · 181 阅读 · 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 · 143 阅读 · 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 · 215 阅读 · 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 · 239 阅读 · 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 · 169 阅读 · 0 评论 -
2.add-two-numbers, golang
code:/**Definition for singly-linked list.type ListNode struct {Val intNext *ListNode}*/func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {if nil == l1 {return l2} else i...原创 2019-10-17 09:42:50 · 215 阅读 · 0 评论 -
1.two-sum, golang
code:type KeyValue struct {Key intValue int}type ArrKV []KeyValuefunc (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 · 213 阅读 · 0 评论
分享