mock interview
文章平均质量分 73
喵喵旺
这个作者很懒,什么都没留下…
展开
-
[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 · 311 阅读 · 0 评论 -
[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 · 273 阅读 · 0 评论 -
[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 · 243 阅读 · 0 评论 -
[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 · 361 阅读 · 0 评论 -
[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 · 192 阅读 · 0 评论 -
[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 · 210 阅读 · 0 评论 -
[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 · 168 阅读 · 0 评论 -
[Amazon] Reverse Words in a Stri
题目大意:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".选这个题目写blog,是让自己认识一个必须认识的符号 "\\s+", 顺便用此题举例该符号使用方法。正则表达式原创 2017-03-16 06:10:22 · 263 阅读 · 0 评论 -
[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 · 202 阅读 · 0 评论 -
[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 · 299 阅读 · 0 评论 -
[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 · 691 阅读 · 0 评论 -
[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 · 389 阅读 · 0 评论 -
[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 · 198 阅读 · 0 评论 -
[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 · 396 阅读 · 0 评论 -
[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 · 174 阅读 · 0 评论