自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(121)
  • 收藏
  • 关注

转载 负载均衡算法

前言  之前写过一个多进程异步服务系统的小项目,里面对于多个进程之间使用的负载均衡算法。就是最简单的轮询办法,但是这种算法存在一个比较大的问题,如果其中一个服务器出现问题,那下一个服务器的负载会增大两倍。基于这个问题我这几天在看Go语言高级编程的书的时候,发现作者写了有关于负载均衡的章节,因此这里拿来学习一下。  原书地址:https://github.com/chai20...

2019-08-12 21:07:00 220

转载 【LeetCode每天一题】Excel Sheet Column Title(Excel的表格数)

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA...

2019-06-11 15:52:00 171

转载 【LeetCode每天一题】Two Sum II - Input array is sorted(两数之和-有序数组)

Given an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbe...

2019-06-09 15:18:00 156

转载 【LeetCode每天一题】Find Peak Element(找到峰值元素)

A peak element is an element that is greater than its neighbors.Given an input arraynums, wherenums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple peaks...

2019-06-08 16:03:00 164

转载 【LeetCode每天一题】 Intersection of Two Linked Lists(两个链表的入口节点)

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Inp...

2019-06-07 20:19:00 107

转载 【LeetCode每天一题】Find Minimum in Rotated Sorted Array(旋转数组中最小的值)

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7]might become [4,5,6,7,0,1,2]).Find the minimum element.You may assume n...

2019-06-06 10:06:00 85

转载 【LeetCode每天一题】Maximum Product Subarray(子数组的最大积)

Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output: 6Explanation:[...

2019-06-05 15:59:00 74

转载 【Mysql】索引

  索引在mysql中的作用主要是在海量数据中快速查找到指定的数据。在设计数据表格的时候应该对列添加索引也是一个重要的问题,因为这决定了在查找数据时查找速度,当然数据很大时,设计不好的索引不仅不能加速查找,反而会变得更加慢。因此设计一个好的索引是非常重要的一个问题,但是怎么的索引的才是一个好索引?这就需要我们对索引有深入了解。基于此我打算从以几个方面进行总结:(1)索引的类型、(2)高性...

2019-06-05 15:23:00 97

转载 【LeetCode每天一题】Insertion Sort List(使用插入法对链表进行排序)

Sort a linked list using insertion sort.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1->0->3->4->5思...

2019-06-04 11:48:00 89

转载 【LeetCode每天一题】Binary Tree Preorder Traversal(前序遍历)

Given a binary tree, return thepreordertraversal of its nodes' values.Example:Input: [1, null, 1,2,3 ] 1 \ 2 / 3Output:[1,2,3]Follow up:Recursive solution ...

2019-06-02 17:17:00 91

转载 【LeetCode每天一题】Linked List Cycle II(循环链表II)

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.To represent a cycle in the given linked list, we use an integerposwhich represents the position ...

2019-05-31 19:16:00 81

转载 【LeetCode每天一题】Word Break()

Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.Note:...

2019-05-30 17:15:00 69

转载 【LeetCode每天一题】Candy(分糖果)

There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least...

2019-05-29 19:59:00 399

转载 【LeetCode每天一题】Single Number II(数组中单个数字II)

Given anon-emptyarray of integers, every element appearsthreetimes except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime comple...

2019-05-27 16:58:00 110

转载 【LeetCode每天一题】Gas Station(汽油站)

There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from stationito i...

2019-05-26 11:43:00 134

转载 【LeetCode每天一题】Single Number(数组中单独的数字)

Given anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it witho...

2019-05-26 11:18:00 137

转载 【LeetCode每天一题】Sum Root to Leaf Numbers(二叉树所有根到叶节点之和)

Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number 123.Find the ...

2019-05-24 19:17:00 126

转载 【LeetCode每天一题】Longest Consecutive Sequence(最长的连续序列

Given 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:...

2019-05-24 19:01:00 138

转载 【LeetCode每天一题】 Word Ladder(单词阶梯)

Given two words (beginWordandendWord), and a dictionary's word list, find the length of shortest transformation sequence frombeginWordtoendWord, such that:Only one letter can be changed ...

2019-05-23 19:45:00 88

转载 【LeetCode每天一题】 Valid Palindrome(有效的回文)

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome....

2019-05-22 20:30:00 101

转载 【LeetCode每天一题】Best Time to Buy and Sell Stock(买股票的最佳时机)

Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stoc...

2019-05-21 19:42:00 90

转载 【LeetCode每天一题】Flatten Binary Tree to Linked List(二叉树转化为单链表)

Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2...

2019-05-20 11:31:00 80

转载 【LeetCode每天一题】Distinct Subsequences(不同的子序列)

Given a stringSand a stringT, count the number of distinct subsequences ofSwhich equalsT。A subsequence of a string is a new string which is formed from the original string by deleting some ...

2019-05-19 18:56:00 93

转载 【LeetCode每天一题】Path Sum(二叉树的路径和)

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Exa...

2019-05-16 21:06:00 62

转载 【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.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of ...

2019-05-15 20:07:00 155

转载 【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.Note:A leaf is a node with no chil...

2019-05-15 19:50:00 61

转载 【LeetCode每天一题】Balanced Binary Tree(平衡二叉树的判断)

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two subtrees ofeverynode nev...

2019-05-14 19:49:00 127

转载 【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.For example, givenpreorder =[3,9,20,15,7]inorder ...

2019-05-13 19:58:00 65

转载 【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 binary...

2019-05-13 12:01:00 97

转载 【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,null,null,15,7], 3 / \ 9 ...

2019-05-12 15:56:00 114

转载 【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[1,2,2,3,4,4,3]is symmetric: 1 / \ 2 2 / \ / \3 4...

2019-05-12 15:31:00 49

转载 【LeetCode每天一题】Same Tree(相同的树)

Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Examp...

2019-05-11 20:45:00 81

转载 【Go】并发

并发   在Go语言中较为出名的就是他本身支持高并发机制,通过在程序中使用关键字go 函数名() 来创建一个并发任务单元,然后系统将任务单元放置在系统队列中,等待调度器安排合适系统线程去获取执行权并执行任务单元(就是函数)。在这其中每个任务单元保存了该函数的指针、传入的参数、执行所需的栈内空间大小(2KB, 正是由于该原因所以才能创建成千上万的并发任务单元)。  例子:...

2019-05-10 20:53:00 76

转载 【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-05-09 22:04:00 117

转载 【LeetCode每天一题】 Unique Binary Search Trees(唯一二叉搜索树)

Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: ...

2019-05-08 20:41:00 116

转载 【LeetCode每天一题】Binary Tree Inorder Traversal(二叉树的中序遍历)

Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up:Recursive solution is trivi...

2019-05-08 20:18:00 126

转载 【LeetCode每天一题】Reverse Linked List II(旋转链表II)

Reverse a linked list from positionmton. Do it in one-pass.  Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2...

2019-05-06 10:30:00 55

转载 【LeetCode每天一题】Subsets II(子集合II)

Given a collection of integers that might contain duplicates,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: [1,2...

2019-05-05 23:20:00 108

转载 【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 o...

2019-05-04 16:47:00 116

转载 【Go】面向对象

  在Go语言中没有了class 类关键字,但是这并不代表Go语言不能使用面向对象编程,在Go语言中使用了struct关键和interface 关键字来定义对象和方法接口。具体如下:面向对象  Go中使用struct来定义类,假如我们需要定义一个person类,其中包含姓名、年龄等信息。我们可以使用struct关键字来定义(这个和c语言中的struct一样,只不过Go的str...

2019-05-04 13:30:00 91

空空如也

空空如也

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

TA关注的人

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