自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

toward_south的博客

MySQL的开端

  • 博客(43)
  • 收藏
  • 关注

原创 LeetCode - set-matrix-zeroes

题目:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(m...

2019-04-29 21:21:00 120

原创 LeetCode - search-a-2d-matrix

题目:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of eac...

2019-04-27 21:36:42 125

原创 LeetCode - combinations

题目:Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4]...

2019-04-25 12:13:47 201

原创 LeetCode - word-search

题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertica...

2019-04-25 10:37:02 119

原创 LeetCode-remove-duplicates-from-sorted-array-ii

题目:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should return length =5, and A is now[1,1,2,2,3]...

2019-04-24 21:50:16 142

原创 查找-有序表查找

有序表查找,首先是表内有序,它有以下算法1.折半查找2.插值查找3.斐波那契查找Java代码实现:/* *有序表查找 */public class OrderListSearch { /* * 折半查找 * 时间复杂度为O(logn) * * @param a 数组 * @param n 数组大小 * @param key 要...

2019-04-23 21:02:51 407

原创 查找-顺序表查找

顺序表查找,逐一比较,它有以下算法1.顺序查找2.顺序查找优化(加了个哨兵)代码:/* * 顺序查找不等同与顺序表就已经是有序的了,这里需要注意 * 时间复杂度为0(n) * 空间复杂度为1 */public class SequentialSearch { /* * 顺序表查找算法 * @param a 数组 * @param n 数组大小 ...

2019-04-23 20:55:42 287

原创 LeetCode - remove-duplicates-from-sorted-array

题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this in place w...

2019-04-23 20:35:13 159

原创 LeetCode - search-in-rotated-sorted-array

题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value to search. If found in the array return it...

2019-04-22 12:19:03 124

原创 LeetCode - search-in-rotated-sorted-array-ii

题目:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the...

2019-04-22 12:02:30 129

原创 LeetCode - interleaving-stringremove-duplicates-from-sorted-list-ii

题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, return1-&...

2019-04-21 11:26:44 113

原创 LeetCode - remove-duplicates-from-sorted-list

题目:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3....

2019-04-20 11:16:23 150

原创 LeetCode - maximal-rectangle

题目:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.题意:给定一个包含0和1的二维二进制矩阵,找出包含所有1的最大矩形并返回其面积。解题思路:当时我是这么想的直接双重循环,找到等于1的数...

2019-04-20 10:40:03 170

原创 LeetCode -largest-rectangle-in-histogram

题目:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of...

2019-04-19 16:57:59 127

原创 LeetCode - partition-list

题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each...

2019-04-19 10:28:55 103

原创 LeetCode - scramble-string

题目:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ g...

2019-04-18 11:11:56 136

原创 LeetCode - merge-sorted-array

题目:Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements initialized in...

2019-04-17 21:10:04 137

原创 LeetCode - decode-ways

题目:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the...

2019-04-17 20:37:34 115

原创 LeetCode - subsets-ii

题目:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order. The solution set must not contain dupl...

2019-04-16 09:56:29 164

原创 LeetCode -minimum-depth-of-binary-tree

题目:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题意:给定一个二叉树,求它的最小深度。最小深度是从根节点到最近叶子...

2019-04-15 21:07:01 94

原创 LeetCode - subsets

题目:Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets.For exampl...

2019-04-15 20:33:21 100

原创 LeetCode - gray-code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gr...

2019-04-14 11:49:39 109

原创 LeetCode - reverse-linked-list-ii

题目:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given1->2->3->4->5->NULL, m = 2 and n = 4, return1->4->3->2->5->NULL. Note: ...

2019-04-13 12:33:27 62

原创 LeetCode - restore-ip-addresses

题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.255.11.135", "255.255.111.35"]. (Order do...

2019-04-13 11:53:25 80

原创 LeetCode - interleaving-stringbinary-tree-inorder-traversal

题目:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].题意:根据给定的二叉树,返回中序遍历的结点值...

2019-04-12 12:04:25 68

原创 LeetCode - unique-binary-search-trees

题目:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1 3 3 2 1 ...

2019-04-12 11:20:43 75

原创 LeetCode - interleaving-stringunique-binary-search-trees-ii

题目:Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 unique BST's shown below. 1 ...

2019-04-12 10:18:02 72

原创 LeetCode - interleaving-string

题目:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="aadbbbaccc", return false...

2019-04-11 21:50:02 129

原创 LeetCode - validate-binary-search-tree

题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keysless thanthe node's key....

2019-04-09 21:38:39 80

原创 LeetCode - recover-binary-search-tree

题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you dev...

2019-04-08 17:43:37 95

原创 LeetCode -same-tree

题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.题意:给...

2019-04-07 11:56:49 90

原创 LeetCode - symmetric-tree

题目:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the fo...

2019-04-07 11:26:45 84

原创 LeetCode - binary-tree-level-order-traversal

题目:Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,20,#,#,15,7}, 3 / \ 9 20 ...

2019-04-07 10:50:04 63

原创 LeetCode - binary-tree-zigzag-level-order-traversal

题目:Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binar...

2019-04-06 12:00:47 82

原创 LeetCode - maximum-depth-of-binary-tree

题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.题意:给定一个二叉树,求它的最大深度。最大深度是从根...

2019-04-06 11:11:39 118

原创 LeetCode - construct-binary-tree-from-preorder-and-inorder-traversal

题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题意:根据前序序列和中序序列来构造二叉树可以假设二叉树中没有重复的数解题思路:中...

2019-04-06 10:53:31 78

原创 LeetCode - construct-binary-tree-from-inorder-and-postorder-traversal

题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题意:给你一个二叉树的中序序列和后序序列,确定二叉树。里面的结点不重复解题思路:...

2019-04-05 12:09:54 124

原创 LeetCode - binary-tree-level-order-traversal-ii

题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree{3,9,20,#,#,15,7},...

2019-04-05 09:54:01 86

原创 LeetCode - convert-sorted-array-to-binary-search-tree

题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题意:将一个有序的数组转化为二叉查找树解题思路:这题和上一题convert-sorted-list-to-binary-search-tree这题差不多还是找出数组中点,以该中...

2019-04-04 11:12:04 122

原创 LeetCode -convert-sorted-list-to-binary-search-tree

题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意:将有序链表转化为二叉查找树解题思路:通过快慢指针找到链表中点然后以该中点来建立二叉查找树递归遍历以中点左边的树(包括中点)递归遍历以中...

2019-04-04 10:22:30 81

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除