- 博客(52)
- 资源 (6)
- 收藏
- 关注
原创 287. 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
2016-08-31 08:24:52 420
原创 112. 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.For example: Given the below binary tree and sum = 2
2016-08-30 22:41:17 401
原创 328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac
2016-08-30 08:01:13 427
原创 318. 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-08-29 22:33:15 480
原创 389. Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in
2016-08-29 08:09:47 655
原创 12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question就是找规律public class Solution { public Str
2016-08-27 14:11:09 482
原创 238. Product of Array Except Self
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 nums[i].Solve it without division and in O(n).For e
2016-08-26 20:47:03 514
原创 384. Shuffle an Array
Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nums);// Shuffle the array [1,2,3] and return its res
2016-08-26 08:44:03 611
原创 343. 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-08-25 22:33:01 357
原创 319. Bulb Switcher
题目大意是,有n只初始处于关闭状态的灯泡。你首先打开所有的灯泡(第一轮)。然后,熄灭所有序号为2的倍数的灯泡。第三轮,切换所有序号为3的倍数的灯泡(开着的就关掉,关着的就打开)。第n轮,你只切换最后一只灯泡。计算n轮之后还有几盏灯泡亮着。 先看看以下规律: 第1个灯泡:1的倍数,会改变1次状态: off -> on 第2个灯泡:1的倍数,2的倍数,会改变2次状态: off -> on -> o
2016-08-25 22:12:53 383
原创 357. Count Numbers with Unique Digits
Count Numbers with Unique Digits QuestionEditorial Solution My Submissions Total Accepted: 13025 Total Submissions: 29945 Difficulty: Medium Given a non-negative integer n, count all numbers with
2016-08-25 18:07:38 372
原创 347. Top K Frequent Elements
Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele
2016-08-25 16:56:05 392
原创 python Scapy 随心所欲撩tcp协议栈
1. 前言如果只需要研究Linux的tcp协议栈行为,只需要使用packetdrill就能够满足我的所有需求。packetdrill才是让我随心所欲地撩tcp协议栈。packetdrill的简单使用手册。然而悲剧的是,除了要研究Linux的TCP协议栈行为,还需要研究Windows的tcp协议栈的行为,Windows不开源,感觉里面应该有挺多未知的坑。为了能够重现Windows的tcp协议栈的一些网
2016-08-25 00:25:14 18162
原创 Linux TCP 协议栈数据流走读
1. 综述Linux的TCP协议非常复杂,看了几天Linux内核的tcp实现犹如雾里看花。在这里主要是根据书籍《The Linux Networking Architecture》 24章,以及结合网上的资料,走读一遍tcp协议的数据流的发送和接收。而内核源码是Centos 7.2的标准内核3.10。这个版本和书中的介绍的函数有点不一样。tcp的数据流就是tcp数据的发送和接收两个方面。具体的系统调
2016-08-24 22:34:39 4966
原创 268. Missing Number
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, 3] return 2.Note: Your algorithm should run in line
2016-08-24 21:40:17 386
原创 338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you sh
2016-08-24 08:28:27 383
原创 260. Single Number III
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 that appear only once.For example:Given nums = [1,
2016-08-23 21:15:24 419
原创 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted 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 numbers suc
2016-08-23 20:34:11 350
原创 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribe to see which companies asked this question解题思路:思路1:将整数转化成字符串,然后对比。这个需要额外的空间。思路2: 就是分别从两端取得数字,然
2016-08-23 07:57:22 411
原创 172. Factorial Trailing Zeroes
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space?Subscribe to see which co
2016-08-23 07:37:40 298
原创 119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space?Subscribe to see which co
2016-08-22 23:58:52 288
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode” return 0.s = “loveleetcode”, return 2. Note: You may assume
2016-08-22 22:18:16 873
原创 读《张爱玲:她从海上来》有感
这本书讲述了张爱玲的生平故事以及在她人生出现的几个重要人物。在这本书上可以深刻体会到张爱玲的人生是多么的曲折传奇。无论是人物铺排还是在穿插各种小故事,都可以深入理解张爱玲这个人物的特质。主线是以张爱玲的成长为主,生活环境转移为辅。1. 南京这里主要讲述张爱玲的父辈的生活。张爱玲系出名门,祖父张佩纶是清末名臣,祖母李菊耦是朝廷重臣李鸿章的长女。祖父为了躲避了朝廷的纷争,隐居于南京。故事从这里开始。在
2016-08-20 07:45:21 1076
原创 58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined as
2016-08-20 07:06:20 304
原创 118. Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] Subscribe to see which compan
2016-08-19 22:18:11 334
原创 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional
2016-08-19 08:10:57 326
原创 67. Add Binary
Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.Subscribe to see which companies asked this question解题思路:用0补齐最短字符串左侧,至两字符串等长,如 a = “1111”
2016-08-18 08:42:45 276
原创 28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Subscribe to see which companies asked this question解题思路:这道题是一个字符串在另外一个字符串中的第
2016-08-17 21:35:35 277
原创 198. House Robber
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 you from robbing each of them is that adjacent houses
2016-08-17 19:03:51 338
原创 13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question解题思路: 根据罗马数字的规律,这个数字,小于等于左边的数字,表示需要+,而大于左边的
2016-08-17 13:10:27 331
原创 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The result can be in
2016-08-17 08:41:28 268
原创 350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times as it
2016-08-17 08:06:48 281
原创 371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.Credits: Special thanks to @fujiaozhu for adding this problem a
2016-08-16 21:01:50 316
原创 Packetdrill 简明使用手册
1. Packetdrill 编译与安装源码链接 https://github.com/google/packetdrill.git源码编译注释netdev.c/* Set the offload flags to be like a typical ethernet device */static void set_device_offload_flags(struct local_ne
2016-08-16 09:07:10 4235
原创 226. Invert Binary Tree
Invert a binary tree.4/ \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howell: Goo
2016-08-16 08:11:21 349
原创 7、Java类集
1. 类集框架主要接口在整个Java类集中最常使用的类集接口是:Collection:是存放一组单值的最大父接口,所谓的单值是指集合中的每个元素都是一个对象。List:是Collection接口的子接口,也是最常用的接口。Set:是Collection接口的子类,没有对Collection接口进行扩展,不允许存放重复内容。Map:是存放一对值的最大父接口,即接口中的每个元素都是一对,以key
2016-08-15 22:42:05 635
原创 6、Java 常用类库
1. StringBuffer类String的内容一旦声明则不可改变,如果要改变,则改变的肯定是String的引用地址,那么如果现在的情况是一个字符串要被经常改变,此时就必须使用StringBuffer类,通过append()方法进行字符串的连接。常见用法如下所示:public StringBuffer() //StringBuffer构造方法public StringBuffer append(
2016-08-15 22:24:37 443
原创 5、Java泛型
1. 泛型的基本应用泛型可以解决数据类型的安全性问题,其主要原理是在类声明时通过一个标识表表示类中某个属性的类型或者某个方法的返回值及参数类型。这样在类声明或者实例化时只要制定好需要的具体的类型即可。class Notepad<K,V>{ private K key; private V value; public K getKey(){ return key;
2016-08-15 22:07:09 411
原创 4、Java 包及访问控制权限
1. 系统常见包java.lang 此包为基本的包,String,Inter等等常用类都保存在此包中java.lang.reflect 此包为反射机制的包,是java.lang的子包,在Java反射机制会介绍。java.util 此包为工具包,一个常用的类库,日期操作等在此包中,如果把此包掌握精要。java.text 提供了一些常用的类库、日期操作等在此包中。java.sql 数据库操作包
2016-08-15 21:58:32 448
原创 3、Java 异常的捕获及处理
1. 异常类的继承结构在整个Java的异常结构中,实际上有两个最常见的类,分别是Excepttion和Error,这两个类全都是Throwable的子类。Exception:一般表示的是程序中出现的问题,可以直接使用try…catch处理。Error:一般指的JVM的错误,程序中无法处理。一般情况下,开发者习惯于将Excepttion和Error统称为异常,而算术异常、数字格式化异常等都属于Exce
2016-08-15 21:54:53 808
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人