自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Json DFS parse(PG)

JSON format Data{"GB": {"birmington": {"apple": "20", "google": "50", ....},. more info on 1point3acres.com"london": {"apple": "110", "google": "70", ....},.....},"US": {"new york": {"apple"

2016-12-08 15:44:15 513

原创 欢迎使用CSDN-markdown编辑器

Company Tree/* package whatever; // don't place package name! */import java.io.*;import java.util.*;//company Treeclass ResultWrapper{ int sum; int num; double maxAvg;

2016-11-24 07:22:34 388

原创 Very Important:How to design HashMap

1.Data Structure need to store the key-value Pair Make an Entry Class to Store the HashMap Entries Variable: key value and next next(Entry) variable is used to avoid the collision pf hashmap using c

2016-11-04 03:32:27 437

原创 Godaddy OA:delete node larger than X

注意到,里面有2种方法,第一种方法是只有一个节点,这个删除节点方法和LeetCode里面一提delete指定node相类似.但是有一个问题是当我走到最后一个节点的时候,如果这个节点的value是大于指定的X的话,我怎么也删除不了该节点,我想到的办法是将 该节点前面的节点用prev来标注, 之后 再一个一个的向右移动. 见第二个方法DeleteNodeWaypackage com.company;/

2016-10-22 09:37:07 619

原创 Facebook面试题:Task Schedule

第一题是Task Schedule, 地里有面经。大致意思是每种task都有冷却时间,比如task1执行后,要经过interval时间后才能再次执行,求总共所需时间。. 1point3acres.com/bbs Sample 1 tasks: 1, 1, 2, 1. recovery interval: 2 output: 7 (order is 1 _ _ 1 2 _ 1) Samp

2016-10-17 04:23:53 2310

原创 Facebook面试题:Sort partial Array

Sort Partial Array

2016-10-06 14:20:21 416

原创 LeetCode376. Wiggle Subsequence

public class Solution { public int wiggleMaxLength(int[] nums) { if(nums==null||nums.length==0) return 0; if(nums.length<2) return nums.length; int[] dp = new int[nums.length

2016-10-05 12:16:55 273

原创 LeetCode32. Longest Valid Parentheses

Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which has

2016-10-04 05:20:26 284

原创 F面经:判断数组是否单调以及Trie Tree不加wildcard 加句号

判断数组是否是单调 注意可能是单增也可能是单减。 先用了 ([i]-[i+1])*([i+2]-[i+1])<0判断,但是面试官说可能有重复, 比如 [5,6,8,8,7]所以老老实实从左开始扫描,定一个flag,如果小了就flag设成-1,并且设之前先看flag是否等于1,如果是就说明不单调。 flag初始为02.add and search的变种,lc是check的时候有wildcard,这

2016-10-04 04:18:52 546

原创 九章算法笔记10.3 part2

一个最小堆1.二叉树 用数组来实现,在树上面对TreeNode 编号id:0,1,2,3,4,5 1,3,5,10,11,15leftson = 2*id+1 rightson = 2*id+2 parent = (id-1)/2堆push元素的话,直接在数组后面加一个index就可以了,push的时间复杂度O(logn),pop操作就是和和末尾交换元素,之后pop出去末尾一个元

2016-09-28 14:20:47 796

原创 九章算法笔记:Union find

Union find有一颗二叉树 C D A B C指向的结点D, A和B指向结点C 下图 上一行是子节点 下一行是父亲节点 如果要找A的big father的话,先从A找到C,再从C找到D 并查集 查找 find 要O(n)的时间复杂度 union需要O(n)的时间复杂度 重要: 如果有一个链表,这个链表最后都指向最后一个元素,now you wanna find b

2016-09-27 14:07:13 1575

原创 LeetCode295:Find Median from Data Stream

最大最小堆 时间复杂度 O(NlogN) 空间O(N) 维护一个最大堆,一个最小堆,最大堆存的是到目前为止较小的那一半数,最小堆是到目前为止较大的那一半数 最大堆是目前为止较小的那一半数最好在脑子里面形成一个图,这个图是这样的, 最大堆上面的元素是最大的,下面都是比堆顶元素要小,最小堆上的元素是最小的,说明堆顶元素以下都是比堆顶元素要大的。 这样的话,自然而然的就知道,最大堆 最小堆存储的元素,

2016-09-26 13:24:50 347

原创 Leetcode140:Word Break II

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given ***s = “ca

2016-09-20 06:28:24 313

原创 leetcode50. Pow(x, n)

这道题是用brute force做出来的,时间复杂度是O(n) 分n次方的n是正数还是负数2个方面去讨论的.但是leetcode test case: x=0.00001 n=2147483647时,整个程序会超时 Time Limit Exceeded.public class Solution { public double myPow(double x, int n) {

2016-09-20 06:11:14 702

原创 Leetcode3:Longest Substring Without Repeating Characters

Method 1: Set for(int i=0……) 后设置一个Set,每次将没有在Set出现的字符加入到Set中,然后记录此时此刻的substring长度。每次取最大的的长度.刚开始写的时候 把Set写在第二个循环里面了,这样的话,每次进入第二个循坏都会创建一个新的Set。 这样的话,Set为空,每次取出来的字符都是第j位。这样判断Set.contains(c) 就没有意义了public i

2016-09-04 21:22:15 321

原创 PriorityQueue里面的的minheap和maxheap

static class PQsort implements Comparator<Integer> { public int compare(Integer one, Integer two) { return two - one;//或者返回负数 如-1 } }//这个是max heap的代码假设有数组 int[] ia = { 1,

2016-08-30 11:18:07 3752

转载 线段树&315 LeetCode:Count of Smaller Numbers After Self

一:线段树的基本概念线段树是一颗二叉搜索树,与区间树相似,讲一个区间划分成一些单元区间,每一个单元区间对应线段树中一个叶子节点线段树上的每一个非叶子节点[a,b],它的左儿子表示区间为[a,(a+b)/2], 右儿子表示的区间为[(a+b)/2+1,b]。因此线段树是平衡二叉树,最后的子节点的数目为N。即是整个线段区间的长度。You are given an integer array nums

2016-08-30 04:58:47 1083

原创 Leetcode32:Longest Valid Parentheses

Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, which has

2016-08-19 06:20:46 437

原创 Leetcode:Valid Anagram

Valid Anagram的思路很简单,就是先将string转化为字符串数组,通过字符串数组在对 数组进行排序。在转化为String, 之前我想的是,先讲String1转化为数组,再将数组里面的字符存在map里面,再将String2转化为数组,将数组里面的字符放在map里面,再将map里面的value拿出来是不是为2,这样根本不行,因为一个字符串里面出现字母的频率肯定不是1char[] s1 = s

2016-08-01 05:27:22 305

原创 TopKElements和Hashmap的空间复杂度问题

hashmap的空间复杂度,比如,we need to find the top frequency word in an array,so we need to use hashmap then the space complexity is O(n).if we use brute force method,firstly,sort the array,it cost O(nlgn) ti

2016-03-09 12:19:53 2532

原创 Leetcode:195. Tenth Line以及管道命令pipeline

195. Tenth LineMy SubmissionsQuestionTotal Accepted: 9416 Total Submissions: 29373 Difficulty: EasyHow would you print just the 10th line of a file?For example, assume that f

2016-03-07 05:41:21 607

原创 Leetcode:BinaryTree level order Traversal and Zigzag traversal

Given a binary tree, return the bottom-up level order traversal 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},

2016-03-06 07:39:54 276

原创 USC CSCI 585 Specialization Hierarchy

Provide the means to:   Support attribute inheritance   Define a special supertype attribute known as the subtype discriminator   Define disjoint/overlapping constraints and compete/partial cons

2016-03-03 08:30:23 1032

转载 sql having 语句

HAVING 子句在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与合计函数一起使用。SQL HAVING 实例我们拥有下面这个 "Orders" 表:O_IdOrderDateOrderPriceCustomer12008/12/291000Bush

2016-03-02 13:09:55 568

转载 Group by and Having用法解析

Group By语句的意思就是很据(by)一定的规则进行分组(Group), 作用就是通过一定的规则将一个数据集化为若干个小区域,然后针对若干个小区域进行数据处理例如现在有这样一张表,每个部门有多少人 就需要用到这样一张表select DepartmentID as "部门名称"  COUNT(*) as   '个数' from BasicDepartment group

2016-03-02 12:04:54 1799

原创 LeetCode:181. Employees Earning More Than Their Managers

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary |

2016-03-01 10:10:01 362

原创 Leetcode:Rising Temperature database

leetcode database

2016-03-01 08:56:41 381

原创 LEETCODE database 183. Customers Who Never Order

leetcode 183

2016-02-29 07:09:38 409

空空如也

空空如也

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

TA关注的人

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