• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
03 2015 档案
CareerCup: 17.14 minimize unrecognized characters

摘要:Oh, no! You have just completed a lengthy document when you have an unfortu-nate Find/Replace mishap. You have accidentally removed all spaces, p... 阅读全文
posted @ 2015-03-22 11:55 neverlandly 阅读(751) 评论(0) 推荐(0)
转载:如何在面试中写出好的代码

摘要:一下都是我面试的经验和教训,欢迎各位大牛指正或者补充 1. 写代码之前,大脑里面要有个whole picture,不能想到哪儿写到哪儿。是你的大脑在写代码,而不是白板上你的手在代码。你的手只是一个printer里面的喷头而已,是它把你大脑里面的代码print到白板上,你的大脑才是控制那个喷头的芯片。 阅读全文
posted @ 2015-03-19 03:55 neverlandly 阅读(1770) 评论(0) 推荐(1)
F面经:painting house

摘要:There are a row of houses, each house can be painted with three colors red, blue and green. The cost of painting each house with a certain color is di... 阅读全文
posted @ 2015-03-18 04:49 neverlandly 阅读(1618) 评论(0) 推荐(0)
Lintcode: Merge Sorted Array II

摘要:Merge two given sorted integer array A and B into a new sorted integer array.ExampleA=[1,2,3,4]B=[2,4,5,6]return [1,2,2,3,4,4,5,6]ChallengeHow can you... 阅读全文
posted @ 2015-03-16 04:41 neverlandly 阅读(600) 评论(0) 推荐(0)
Lintcode: Median

摘要:Given a unsorted array with integers, find the median of it. A median is the middle number of the array after it is sorted. If there are even numbers ... 阅读全文
posted @ 2015-03-16 03:56 neverlandly 阅读(1752) 评论(0) 推荐(0)
Climbing Stairs - Print Path

摘要:stair climbing, print out all of possible solutions of the methods to climb a stars, you are allowed climb one or two steps for each time; what is tim... 阅读全文
posted @ 2015-03-15 11:35 neverlandly 阅读(558) 评论(0) 推荐(0)
Lintcode: Maximum Subarray III

摘要:Given an array of integers and a number k, find k non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguou... 阅读全文
posted @ 2015-03-14 10:53 neverlandly 阅读(468) 评论(0) 推荐(0)
Leetcode: Reverse Bits

摘要:Reverse Integer那道题会考虑溢出,因为那是reverse each digit,这里不会溢出,因为reverse的是each bit Q:如果该方法被大量调用,或者用于处理超大数据(Bulk data)时有什么优化方法?A:这其实才是这道题的精髓,考察的大规模数据时算法最基本的优化方法 阅读全文
posted @ 2015-03-14 07:06 neverlandly 阅读(779) 评论(0) 推荐(0)
Leetcode: 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 i... 阅读全文
posted @ 2015-03-14 06:02 neverlandly 阅读(479) 评论(0) 推荐(0)
Lintcode: Maximum Subarray II

摘要:Given an array of integers, find two non-overlapping subarrays which have the largest sum.The number in each subarray should be contiguous.Return the ... 阅读全文
posted @ 2015-03-14 05:49 neverlandly 阅读(479) 评论(0) 推荐(0)
Lintcode: Maximum Subarray Difference

摘要:Given an array with integers.Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest.Return the largest difference.NoteThe ... 阅读全文
posted @ 2015-03-14 05:16 neverlandly 阅读(1210) 评论(0) 推荐(0)
Lintcode: Majority Number II

摘要:Given an array of integers, the majority number is the number that occurs more than 1/3 of the size of the array.Find it.NoteThere is only one majorit... 阅读全文
posted @ 2015-03-12 06:50 neverlandly 阅读(1240) 评论(0) 推荐(0)
Lintcode: Lowest Common Ancestor

摘要: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 large... 阅读全文
posted @ 2015-03-12 05:42 neverlandly 阅读(552) 评论(0) 推荐(0)
Twitter OA prepare: Two Operations

摘要:准备T家OA,网上看的面经最直接的方法,从target降到1,如果是奇数就减一,偶数就除2 1 public static void main(String[] args) { 2 int a = shortest(17); 3 System.out.println(a)... 阅读全文
posted @ 2015-03-09 11:54 neverlandly 阅读(680) 评论(0) 推荐(0)
Twitter OA prepare: even sum pairs

摘要:思路:无非就是扫描一遍记录奇数和偶数各自的个数,比如为M和N,然后就是奇数里面选两个、偶数里面选两个,答案就是M(M-1)/2 + N(N-1)/2 阅读全文
posted @ 2015-03-09 11:51 neverlandly 阅读(477) 评论(0) 推荐(0)
Twitter OA prepare: K-complementary pair

摘要:2sum的夹逼算法,需要sort一下。本身不难,但是tricky的地方在于允许同一个数组元素自己跟自己组成一个pair,比如上例中的[5, 5]。而且数组本身就允许值相等的元素存在,在计算pair时,算成不同的pair,比如数组是[3,3],K=6,这时的pair有[0, 0], [0, 1], [... 阅读全文
posted @ 2015-03-09 11:50 neverlandly 阅读(474) 评论(0) 推荐(0)
Twitter OA prepare: Anagram is A Palindrome

摘要:Algorithm:Count the number of occurrence of each character.Only one character with odd occurrence is allowed since in a palindrome maximum number of c... 阅读全文
posted @ 2015-03-09 11:47 neverlandly 阅读(399) 评论(0) 推荐(0)
Twitter OA prepare: Visit element of the array

摘要:分析:就是建立一个boolean array来记录array里面每个元素的访问情况,遇到访问过的元素就停止visiting,返回未访问的结点个数 1 public int visiting(int[] A, int N) { 2 if (A==null || A.length==0) ret... 阅读全文
posted @ 2015-03-09 11:41 neverlandly 阅读(366) 评论(0) 推荐(0)
Lintcode: Longest Common Substring

摘要:Given two strings, find the longest common substring.Return the length of it.NoteThe characters in substring should occur continiously in original str... 阅读全文
posted @ 2015-03-09 11:33 neverlandly 阅读(454) 评论(0) 推荐(1)
Lintcode: Longest Common Subsequence

摘要:Given two strings, find the longest comment subsequence (LCS).Your code should return the length of LCS.ExampleFor "ABCD" and "EDCA", the LCS is "A" (... 阅读全文
posted @ 2015-03-09 08:11 neverlandly 阅读(738) 评论(0) 推荐(1)
Lintcode: Kth Prime Number (Original Name: Ugly Number)

摘要:Ugly number is a number that only have factors3,5and7.Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7.The ... 阅读全文
posted @ 2015-03-09 05:28 neverlandly 阅读(1535) 评论(0) 推荐(0)
Lintcode: Kth largest Element

摘要:Find K-th largest element in an array.NoteYou can swap elements in the arrayExampleIn array [9,3,2,4,8], the 3rd largest element is 4In array [1,2,3,4... 阅读全文
posted @ 2015-03-09 03:49 neverlandly 阅读(1619) 评论(0) 推荐(0)
Lintcode: k Sum

摘要:Given n distinct positive integers, integer k (k i) res[i][j][t] = 0;18 else res[i][j][t] = res[i-1][j][t];19 ... 阅读全文
posted @ 2015-03-07 05:22 neverlandly 阅读(545) 评论(0) 推荐(0)
VMware Coding Challenge: The Heist

摘要:类似BackpackII问题 1 static int maximize_loot(int[] gold, int[] silver) { 2 int[][] res = new int[gold.length+silver.length+1][10001]; 3 ... 阅读全文
posted @ 2015-03-07 03:50 neverlandly 阅读(315) 评论(0) 推荐(0)
VMware Coding Challenge: Removing Duplicates Entries

摘要:1 static LinkedListNode removeDuplicates(LinkedListNode list) { 2 LinkedListNode cur = list; 3 HashSet set = new HashSet(); 4 ... 阅读全文
posted @ 2015-03-07 03:37 neverlandly 阅读(294) 评论(0) 推荐(0)
VMware coding Challenge: Coin Toss Betting

摘要:1 static int CoinTossEndAmount(int betAmount, String coinTossResults) { 2 if (betAmount <=0 || coinTossResults.length() == 0) return betA... 阅读全文
posted @ 2015-03-07 03:33 neverlandly 阅读(313) 评论(0) 推荐(0)
Lintcode: k Sum II

摘要:Given n unique integers, number k (1> kSumII(int A[], int k, int target) { 9 // write your code here10 ArrayList> res = new ArrayList>... 阅读全文
posted @ 2015-03-05 06:51 neverlandly 阅读(1207) 评论(0) 推荐(0)
Lintcode: Interleaving Positive and Negative Numbers

摘要:Given an array with positive and negative integers. Re-range it to interleaving with positive and negative integers.NoteYou are not necessary to keep ... 阅读全文
posted @ 2015-03-05 06:14 neverlandly 阅读(1096) 评论(0) 推荐(1)
Lintcode: Insert Node in a Binary Search Tree

摘要:Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.ExampleGi... 阅读全文
posted @ 2015-03-05 05:00 neverlandly 阅读(1264) 评论(0) 推荐(0)
Amazon OA

摘要:Remove Duplicates from unsorted array,它的错误在于9-10行k out of bound,改成下面这样就没问题了 1 public class removeDuplicates { 2 public static int[] remove(int[] a... 阅读全文
posted @ 2015-03-04 07:01 neverlandly 阅读(1273) 评论(0) 推荐(0)
Leetcode: Best Time to Buy and Sell Stock IV

摘要:这道题在Best Time to Buy and Sell Stock III做过,那道题只是把k取了2而已 递推式依然是 local[i][j]=max(global[i-1][j-1]+max(diff,0),local[i-1][j]+diff), global[i][j]=max(local 阅读全文
posted @ 2015-03-01 12:40 neverlandly 阅读(3464) 评论(0) 推荐(0)
Leetcode: Reverse Words in a String II

摘要:这道题要求in-place做法,不能使用extra space, 那么,做法跟Rotate Array那道题非常相似 (1)reverse the whole array (2)reverse each subarray seperated by ' ' 注意不要忘了reverse最后一个word 阅读全文
posted @ 2015-03-01 07:49 neverlandly 阅读(6591) 评论(0) 推荐(0)
Leetcode: Repeated DNA Sequence

摘要:Naive 方法就是两层循环,外层for(int i=0; i<=s.length()-10; i++), 内层for(int j=i+1; j<=s.length()-10; j++), 比较两个字符串s.substring(i, i+10)和s.substring(j, j+10)是否equal 阅读全文
posted @ 2015-03-01 07:31 neverlandly 阅读(479) 评论(1) 推荐(0)
Leetcode: Rotate Array

摘要:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:... 阅读全文
posted @ 2015-03-01 05:19 neverlandly 阅读(1726) 评论(0) 推荐(0)

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3