自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [US Giants] 六. Linked List

Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.The minimum number of nodes in list is n.ExampleGi

2017-07-31 10:54:04 298

原创 [US Giants] 五. Greedy

Single NumberGiven 2*n + 1 numbers, every numbers occurs twice except one, find it.Example:Given [1,2,2,1,3,4,3], return 4Challenge :One-pass, constant extra space.思路:HashMap

2017-07-29 00:30:25 305

原创 [US Giants] 四.Math & Bit Manipulation

Trailing ZerosWrite an algorithm which computes the number of trailing zeros in n factorial.Example11! = 39916800, so the out should be 2Challenge O(log N) time思路

2017-07-27 10:05:49 389

原创 [US Giants] 三. Binary Search

Sqrt(x) :点击打开链接Implement int sqrt(int x).Compute and return the square root of x.Examplesqrt(3) = 1sqrt(4) = 2sqrt(5) = 2sqrt(10) = 3Challenge O(log(x))cl

2017-07-26 09:54:47 289

原创 [Algorithm] Rotate 问题

Rotate StringGiven a string and an offset, rotate string by offset. (rotate from left to right)Have you met this question in a real interview? YesExampleGiven "abcdef

2017-07-25 02:52:12 316

原创 [US Giants] 二. Integer-Array

50. Product of Array Exclude Itself点击打开链接思路:两趟循环,对于每一个output[i]={i前面的数的乘积}*{i后面的数的乘积}           第一趟正向遍历数组,对于每个Xi计算Xo~Xi-1的连续乘积   第二趟反向遍历数组,对于每个Xi计算Xn-1~Xi+1的连续乘积例如:A={2,3,4};

2017-07-23 09:59:56 331

原创 [US Giants] 一. String

Given two strings, find the longest common substring.Return the length of it. NoticeThe characters in substring should occur continuously in original string. This is different with subsequ

2017-07-20 06:18:47 585

原创 [高频] 六.数学,几何计算,位运算常见问题

38. Search a 2D Matrix II:点击打开链接[ [1, 3, 5, 7], [2, 4, 7, 8], [3, 5, 9, 10]]思路:从第一行最后一个元素(或者第一列最后一个元素)开始遍历,记此元素为x 如果x<target,砍掉第一行 如果x>target,砍掉最后一列 ...

2017-07-18 03:48:21 725

原创 [LeetCode] 191. Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000

2017-07-18 03:34:03 302

原创 [Microsoft] Search a 2D Matrix

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 from left to right.The first integer of each ro

2017-07-15 20:14:32 288

原创 [Microsoft] Find Peak Element

There is an integer array which has the following features:The numbers in adjacent positions are different.A[0] A[A.length - 1].We define a position P is a peek if:A[P] > A[P-1] && A[P] > A[P

2017-07-15 19:56:52 200

原创 [Microsoft] Identical Binary Tree

Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value.Example 1 1 / \

2017-07-15 19:54:28 224

原创 [Microsoft] Linked List Cycle

/** * Definition for ListNode. * public class ListNode { * int val; * ListNode next; * ListNode(int val) { * this.val = val; * this.next = null; * } * } */ p

2017-07-15 19:51:44 178

原创 [Microsoft] O(1) Check Power of 2

Using O(1) time to check whether an integer n is a power of 2.ExampleFor n=4, return true;For n=5, return false;思路:2的幂次方(2^n)的二进制表达法只有一位为1,其他位都为0,而(2^n-1)则是和(2^n)对应位置正好不一样

2017-07-15 03:43:04 409

原创 [Amazon] Continuous Subarray Sum

Given an integer array, find a continuous subarray where the sum of numbers is the biggest. Your code should return the index of the first number and the index of the last number. (If their are duplic

2017-07-14 10:56:11 209

原创 [Amazon] Second Max of Array

Find the second max number in a given array. NoticeYou can assume the array contains at least two numbers.ExampleGiven [1, 3, 2, 4], return 3.Given [1, 2], return 1.思

2017-07-14 10:37:03 398

原创 [Amazon] Longest Substring with At Most K Distinct Characters

Given a string s, find the length of the longest substring T that contains at most k distinct charactersExampleFor example, Given s = "eceba", k = 3,T is "eceb" which its length is 4

2017-07-14 10:26:25 713

原创 [Amazon] Anagrams

Given an array of strings, return all groups of strings that are anagrams. NoticeAll inputs will be in lower-caseExampleGiven ["lint", "intl", "inlt", "code"], return ["lin

2017-07-14 01:32:45 184

原创 [Algorithm] Combination问题

Combination IIIFind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.

2017-07-14 00:49:03 332

原创 [Amazon] Two Strings Are Anagrams (Compare Strings)

Write a method anagram(s,t) to decide if two strings are anagrams or not.What is Anagram?- Two strings are anagram if they can be the same after change the order of characters.Ex

2017-07-13 11:02:33 373

原创 [Amazon] Big Integer Addition

Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. NoticeThe length of both num1 and num2 is Both num1 and num2 contains only digits 0-

2017-07-13 10:57:50 258

原创 [Amazon] Lowest Common Anscestor

Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor is the node with largest depth which is the ancestor of both nodes.

2017-07-13 10:48:00 216

原创 [Amazon] Add Two Numbers I(II)

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i

2017-07-13 07:46:23 308

原创 [Amazon] Partion Array

Given an array nums of integers and an int k, partition the array (i.e move the elements in "nums") such that:All elements k are moved to the leftAll elements >= k are moved to the rightRetu

2017-07-13 04:49:20 321

原创 [高频] 五. 如何高效实现搜索类题目

425. Letter Combinations of a Phone Number:点击打开链接public class Solution { /** * @param digits A digital string * @return all posible letter combinations */ public ArrayList let

2017-07-12 03:48:24 946

原创 [Algorithm] BST问题

BST性质:左边都比root小,右边都比root大BST的中序遍历得到的节点访问顺序是从小到大的顺序98. Valid Binary Search Tree:点击打开链接方法一思路:先中序遍历BST拿到结果list,遍历list里元素,看当前的元素值是不是小于下一个元素值,只要有当前元素值大于等于下一个元素值的,就返回false/** * Definition of Tree

2017-07-12 01:13:02 534

原创 [高频] 四.基础算法和数据结构II

662. Guess Number Game:点击打开链接/* The guess API is defined in the parent class GuessGame. @param num, your guess @return -1 if my number is lower, 1 if my number is higher, otherwise return 0

2017-07-11 04:18:21 561

原创 [LeetCode] 300.Longest Increasing Subsequence

题目大意:点击打开链接reference: 点击打开链接

2017-07-11 03:11:13 248

原创 [高频] 三. 基础算法和数据结构I

641. Missing Intervals: 点击打开链接思路:两端点和一头一尾形成的区间+for循环扫描中间形成的区间例如:{3,4,50,75},lower=0,upper=99,题目可以理解成在0-99的区间,挖去了3,4,50,95四个点,求剩下的区间区间:lower->3-1 75+1->upper 中间{3,4,50,...

2017-07-09 00:39:25 411

原创 [高频] 二.模拟算法和字符串处理技巧

644.Mirror Numbers:点击打开链接思路:从左往右扫一遍,看对应的位置是不是反着的public class Solution { /** * @param num a string * @return true if a number is strobogrammatic or false */ public boolean is

2017-07-07 01:28:31 323

原创 [bigdata] IntelliJ run project

1.如何run project进入Edit Configurations,对Program Arguments进行修改,添加三个参数:参数1:input文件夹路径(根据你存放代码包的路径对参数1进行相对应修改)参数2:output文件夹路径(可指定任意位置)参数3:emotionCategory.txt文件(根据你存放代码包的路径对参数3进行相对应修改)例如:我的三个参数是这样

2017-07-06 03:13:36 298

原创 [bigdata] 基于docker 打开hadoop

cd bigdata-class2cd hadoop-cluster-dockersudo ./start-container.sh./start-hadoop.shls                               (显示当前的文件列表)cd+显示绿色的阴影  (表示还有子目录,不断进行)vi+Driver.j

2017-07-05 09:41:14 271

原创 [高频] 一.Interview Style

512.Decode Ways:点击打开链接思路:总是从f[i]看前i-1位数字能够解析的结果           有两种方式:前i-1位到前i位,只要第i-1位不是数字0,前i位的结果数就是前i-1位的结果数                                 前i-2位到前i位,只要第i-2位和第i-1位两位上的数字介于10和26之间,就会又增加一种结果数注意:1.

2017-07-04 04:11:55 429

原创 [前端面试题]从字符串的第二个字母开始对数组排序

思路:strs.substr(起始位置,子串长度);          子串参数可选,如果不加就是到最后 var strs=['javascript','abcdef','yui','jquery']; alert(strs.sort(function(str1,str2){ str1=str1.substr(1); str2=str

2017-07-01 10:26:19 610

空空如也

空空如也

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

TA关注的人

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