随笔分类 - Algorithm
摘要:1. Preorder Tree Traversal 2. Inorder Tree Traversal 3. Postorder Tree Traversal
阅读全文
摘要:Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adja
阅读全文
摘要:i & -i = i 最低位的 1 所表示的值 i 单数: i & -i = 1 i 双数: i = 2^k1 +...+ 2^kn (k1 <...<kn) i & -i = 2^k1(负数二进制表达 = 其绝对值的二进制表达 + 1)
阅读全文
摘要:A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are give
阅读全文
摘要:Reference : https://leetcode.com/discuss/72701/here-10-line-template-that-can-solve-most-substring-problems 3. Longest Substring Without Repeating Cha
阅读全文
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num
阅读全文
摘要:Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example, Given s = “eceba”, T is "ece" whi
阅读全文
摘要:Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng
阅读全文
摘要:Given an array of integers, every element appears three times except for one. Find that single one. Similar: 136. Single Number 260. Single Number III
阅读全文
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you
阅读全文
摘要:Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm s
阅读全文
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements
阅读全文
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1,
阅读全文
摘要:Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complex
阅读全文
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh
阅读全文
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
阅读全文
摘要:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo
阅读全文
摘要:一个矩阵,求最长连续的序列长度 [1 2 3 4 5 6 7 8 9] 我的解法时用dfs遍历矩阵,如果便利过的元素就标记为false,不再遍历。 邻居 就是上下左右 e.g. 1 2 3 6 5 4 -> 7 7 9 8 =================== 5 7 9 1 2 3 -> 3 4
阅读全文