自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

leetcode 解题思路

FLAG必经之路

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

转载 zz 这个帖子总结的很到位!

作者:Mingche Su链接:https://zhuanlan.zhihu.com/p/21791045来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。给苏哥打个广告,我觉得他们的start up很不错,以后复习就按照这个提纲来复习了。可以系统的把知识提领一遍,把每个东西答出来,至少可以升级一次。以后面试应该都逃不过这个范围了。1.编

2016-07-30 11:22:16 618

原创 今天改bug的心得和最近学习的一些体会

昨天晚上Dan给了我一个bug,说是我的写的代码有问题,需要fix,但是我的代码曾经是经过测试的,而且code review也过了,QA也测试通过了,他提出的一个概念Inbox File System,我根本就没有听说过。所以,我昨天觉得很冤枉,所以就回了,我之前修改的ticket,而且是通过的,这个inbox的东西根本没有在原来的JIRA上面提起过。然后lixin给我找出来,我原来代码中间有个t

2016-07-30 11:11:00 1493

原创 面经 汇总

这里归总一下我最近小伙伴遇见的面经:古哥的Elementum Onsite:第一轮:coding test,给你一部mac,里面有eclipse。在一个2d字符数组里面找是否存在一个字符串,lc原题,不过能跑8个方向。第二轮 找一个字符串的permutation,要求实现有无duplicate的两种,也是lc原题。第二题比较trick,假设我们有一堆螺丝和一堆螺母,他们是一一...

2016-07-30 09:04:40 1929

原创 Insertion Sort Integer Array & Insertion Sort Linked List

Sort Integer Array using Insertion sort.//******************************************************************************************************** /* Insertion Sort 原理:就是前面的sort部分全部是相对值,从后面拿一个元素,然...

2016-07-29 13:26:12 438

转载 F Design 总结

这里原帖地址: http://www.mitbbs.com/article_t/JobHunting/32492515.html以下为转载内容===========================我是分割线==================稍微总结一下1. 入门级的news feedhttp://www.quora.com/What-are-best-prac

2016-07-29 01:15:47 474

原创 private static final long serialVersionUID = 1L 干什么的?

看了一些文章,我的理解就是,这个东西是用来serialization 的key,A和B相互之间传输信息,用seralize,但是相互之间把解包之后的文件进行了更改,如果你程序中不加这个,相互之间再传输,会因为这个key不一样,而失败。所以,在程序中定义,会使软件版本兼容,无论怎么改,都可以相互序列化和反序列化。Java中,如果class实现了序列化接口,你没有加这一行,eclipse会自动给w

2016-07-27 01:59:19 31256 8

原创 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.思路:jame bond 的思路,找mid的前一个点,然后两边分开找;这里只传递一个参数;/** * Definition for singly-linked list....

2016-07-25 12:47:40 329

原创 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 p

2016-07-25 08:40:58 265

原创 Observer Pattern

Observer Pattern.恩,今天总算搞懂了这个pattern,之前都是浆糊。哈哈。我的象形理解就是,所有的大汉想观察一个姑娘,然后都逼迫着这个姑娘拿自己的本子记录下大汉的名字,然后登记在姑娘的list上面,然后以后姑娘有什么动静update或者delete什么东西,必须通知名单上所有的大汉。因为大汉的class里面,构造的时候已经有了姑娘的object,所以大汉只要看看姑娘的状态

2016-07-23 06:48:16 288

原创 Factory Pattern

Factory Pattern.public interface Shape{ public void draw();}public class circle implements Shape { @Override public void draw(){ }}public class rectangle implements Sh

2016-07-23 06:03:17 233

原创 Singleton Pattern

Singleton Pattern:1. Early mode2. Lazy mode:3. Optimize solution:

2016-07-23 05:18:42 278

原创 Product of Array Except Self

Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solve itwithout divisionand in O(n)....

2016-07-23 02:33:38 334

原创 Design Hit Counter

Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being mad

2016-07-22 07:22:53 513

原创 Coin Change

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

2016-07-22 05:47:30 374

原创 Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right. Integers in ...

2016-07-20 14:26:08 269

原创 Wiggle Sort

Given an unsorted array nums, reorder it in-place such thatnums[0] = nums[2] .For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is[1, 6, 2, 5, 3, 4].思路:这题主要在观察规律,并且证明算法的可行性。n

2016-07-20 12:26:15 330

原创 Range Addition

Assume you have an array of lengthninitialized with all0's and are givenkupdate operations.Each operation is represented as a triplet:[startIndex, endIndex, inc]which increments each elemen

2016-07-20 08:03:41 824

原创 Plus One Linked List

Given a non-negative number represented as a singly linked list of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.Example:

2016-07-20 06:08:00 641

原创 Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:找中间点,就是root,然后两边分别构造左子树和右子树。/** * Definition for a binary tree node. * public class TreeNode ...

2016-07-18 08:24:47 320

原创 Paint Fence

There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent fence posts have the same color.Return the to

2016-07-15 10:38:41 529

转载 Ajax, SPA, Client-Side VS Server-Side code difference

Ajax is not a programming language or a tool, but a concept. Ajax is a client-side script that communicates to and from a server/database without the need for a postback or a complete page refresh

2016-07-15 02:55:56 688

原创 Implement Stack using Queues

Implement the following operations of a stack using queues.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- Return ...

2016-07-14 05:42:31 285

原创 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 t

2016-07-13 11:28:59 315

原创 Unique Word Abbreviation

An abbreviation of a word follows the form . Below are some examples of word abbreviations:a) it --> it (no abbreviation) 1b) d|o|g --> d1g

2016-07-13 10:13:55 469

原创 Group Shifted Strings

Given a string, we can "shift" each of its letter to its successive letter, for example:"abc" -> "bcd". We can keep "shifting" which forms the sequence:"abc" -> "bcd" -> ... -> "xyz"Given a l

2016-07-12 11:15:02 437

原创 Range Sum Query - Immutable

Given an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan

2016-07-12 10:33:22 310

原创 Nested List Weight Sum

Given a nested list of integers, return the sum of all integers in the list weighted by their depth.Each element is either an integer, or a list -- whose elements may also be integers or other lis

2016-07-12 07:58:38 331

原创 Logger Rate Limiter

Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it isnot printed in the last 10 seconds.Given a message and a timesta...

2016-07-12 05:59:30 630

原创 Closest Binary Search Tree Value

Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.Note:Given target value is a floating point. You are guaranteed to have only on...

2016-07-12 04:21:22 379

原创 Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.思路:刚开始想的...

2016-07-11 15:10:46 234

原创 Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueTime: O(N) Space: O(N)/** * Definiti...

2016-07-11 14:38:36 221

原创 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"]思...

2016-07-11 14:05:15 224

原创 Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return 964176192 (represented in binary as001110010

2016-07-11 12:52:47 269

原创 Meeting Rooms

Given an array of meeting time intervals consisting of start and end times[[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.ExampleExample1Input: intervals = ...

2016-07-10 02:54:18 258

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

2016-07-09 05:10:51 216

原创 Implement Queue using Stacks

As the title described, you should only use two stacks to implement a queue's actions.The queue should supportpush(element),pop()andtop()where pop is pop the first(a.k.a front) element in the q...

2016-07-08 07:55:51 253

原创 Strobogrammatic Number

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. The number is represented as a...

2016-07-08 07:19:20 316

原创 Flip Game

You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". Th

2016-07-06 14:52:08 258

原创 Reverse Vowels of a String

Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotcede".思路:主

2016-07-06 12:52:01 252

原创 Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could you solve it without

2016-07-06 12:32:13 216

空空如也

空空如也

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

TA关注的人

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