自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 我的面试小结

JAVA基础知识 1、集合 HashMap是如何实现的? 注意是怎么put进去和get出来的,跟什么方法相关(equals和hashcode方法),知道HashMap的数据结构,也就是数组链表,为什么重写了hashcode()一定要重写equals()方法,知道了HashMap的原理,这时候就可以跟面试官举个反例,重写其中一个且不重写另外一个会出现什么样的状况,比如重写了equals(),没有

2016-09-30 17:07:35 328

原创 TCP学习笔记

1.TCP是面向连接的,面向字节流的,首部20字节,首部中没有数据的总长度,但是TCP的接收端会有滑动窗口,并且接收端需要发送确认号,TCP得到此次数据的长度通过接收函数确定数据的长度。关于TCP粘包问题 粘包出现原因:在流传输中出现,UDP不会出现粘包,因为它有消息边界(参考Windows 网络编程) 1 发送端需要等缓冲区满才发送出去,造成粘包 2 接收方不及时接收缓冲区的包,造成多个包

2016-09-30 17:01:16 380

原创 Queue Reconstruction by Height

Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of this p

2016-09-30 16:58:10 662

原创 Largest Divisible Subset

Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple solutions, return

2016-06-29 19:08:47 1561 2

原创 Integer Break

Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1

2016-05-12 21:29:46 220

原创 Maximum Product of Word Lengths

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette

2016-01-17 18:18:27 296

原创 Range Sum Query 2D - Immutable

Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2) The above rectangle (with the red border

2016-01-09 15:05:43 215

原创 Coin Change

You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money c

2015-12-29 21:02:27 416

原创 Remove Duplicate Letters

Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order am

2015-12-13 13:01:58 435

原创 Burst Balloons

Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[lef

2015-12-09 11:34:21 582

原创 Best Time to Buy and Sell Stock with Cooldown

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and

2015-12-06 17:25:30 247

原创 Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2015-11-21 11:31:39 241

原创 Longest Increasing Subsequence

Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], therefo

2015-11-20 11:45:50 229

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of wa

2015-11-15 13:06:25 192

原创 Largest Number

Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be very large,

2015-11-12 16:27:30 258

原创 Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that

2015-11-09 21:09:58 291

原创 拷贝VMware造成mac地址冲突的问题

ifconfig eth0 显示网卡地址出新的网卡地址 修改/etc/sysconfig/network-scripts/ifcfg-eth0文件中的这一项HWADDR,使之与新的网卡地址对应然后重启网络 service network restart

2015-10-31 14:18:15 2749

原创 Find the Duplicate Number

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin

2015-10-28 17:56:08 282

原创 Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path

2015-10-17 10:26:49 271

原创 Course Schedule

There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair:

2015-10-15 08:50:37 220

原创 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 does not

2015-10-13 15:13:11 312

原创 Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]public class Solution { publi

2015-10-11 21:37:07 199

原创 ZigZag Conversion

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I GY

2015-10-08 16:27:12 191

原创 Sort List

Sort a linked list in O(n log n) time using constant space complexity.思路: 利用归并排序的思想,每一次采用快慢指正找出链表的中点,将中点左边的链表进行排序,然后中点右边的链表进行排序,最后将排好序的左右两边的链表进行归并。public class Solution { public ListNode sortList(

2015-10-07 18:57:38 154

原创 Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.思路: 很显然,数组中出现的次数多于 ⌊ n/3 ⌋次数的数字只能出现最多两次。考虑数组中出现次数多于 ⌊

2015-10-07 16:05:29 275

原创 Word Break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet”, “co

2015-09-30 17:30:28 215

原创 Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:

2015-09-30 17:20:03 229

原创 Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].思路: 题目的意思是归并给定的区间。 想象一下,如果所有的区间都是在数轴上按照顺序排列的话,那么归并区间就似乎不那么难

2015-09-30 17:06:15 219

原创 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 devise a const

2015-09-29 09:34:48 219

原创 Candy

There are N children 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 one candy.

2015-09-24 11:36:44 189

原创 First Missing Positive

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 should run in O(n) time and uses constant space.思路

2015-09-22 19:18:07 152

原创 Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may not engag

2015-09-18 20:34:30 165

原创 Maximum Product Subarray

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], the contiguous subarray [2,3] has the largest produ

2015-09-18 20:28:00 163

原创 Jump Game II

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reac

2015-09-18 20:19:28 198

原创 Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements.You may

2015-09-17 10:36:14 331

原创 Group Anagrams

Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note: For the return v

2015-09-17 09:23:04 341

原创 Ugly Number II

Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly

2015-09-13 15:37:07 241

原创 Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return

2015-09-13 14:47:37 238

原创 Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible orde

2015-09-10 17:24:27 272

原创 Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You

2015-09-08 09:45:07 188

空空如也

空空如也

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

TA关注的人

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