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

随笔分类 -  Coding Test

1 2 下一页
Amazon | OA 2019 | Optimal Utilization

摘要:2-Pointers Syntax side: Pay attention to how to print an array: System.out.println(Arrays.toString(int[] item)); 阅读全文
posted @ 2019-10-28 08:16 neverlandly 阅读(1460) 评论(0) 推荐(0)
Amazon | OA 2019 | Movies on Flight

只有注册用户登录后才能阅读该文。
posted @ 2019-10-28 07:04 neverlandly 阅读(3) 评论(0) 推荐(0)
Amzon OA prepare: Treasure Island II

只有注册用户登录后才能阅读该文。
posted @ 2019-10-27 08:51 neverlandly 阅读(3) 评论(0) 推荐(0)
Pocket Gem OA: Log Parser

摘要:涉及到处理Date, 以及STDIN from a file 处理Date可以用SimpleDateFormat这个class static Date parseTime(String timeStr) { Date time = new Date(); DateFormat dft = new S 阅读全文
posted @ 2017-01-28 12:25 neverlandly 阅读(812) 评论(0) 推荐(0)
Pocket Gem OA: Path Finder

摘要:题不难,主要是注意STDIN 阅读全文
posted @ 2017-01-28 12:19 neverlandly 阅读(1026) 评论(0) 推荐(0)
2Sigma OA prepare: Longest Chain

摘要:DP use HashMap: 根据string的长度sort,然后维护每个string的longest chain,default为1,如果删除某个char生成的string能提供更长的chain,则更新 阅读全文
posted @ 2016-12-14 08:19 neverlandly 阅读(8618) 评论(0) 推荐(0)
2Sigma OA prepare: Friends Circle

摘要:DFS & BFS: 关键在于构造graph 如果想把String[] array转化为2d char array, code如下,写的时候这里出了点小问题。friends是String[] Union Find 阅读全文
posted @ 2016-12-14 07:21 neverlandly 阅读(1551) 评论(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 阅读(677) 评论(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 阅读(473) 评论(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 阅读(469) 评论(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 阅读(393) 评论(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 阅读(363) 评论(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 阅读(311) 评论(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 阅读(292) 评论(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 阅读(306) 评论(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 阅读(1268) 评论(0) 推荐(0)
VMware coding Challenge:Date of Weekday

摘要:这道题再次证明了这种细节的题目,画个图容易搞清楚 1 import java.util.Scanner; 2 3 4 public class Solution2 { 5 static int DateOfWeekday(int date, int weekday) { 6 ... 阅读全文
posted @ 2015-02-27 14:09 neverlandly 阅读(510) 评论(0) 推荐(0)
VMware Coding Challenge: Possible Scores && Summary: static

摘要:Combination Sum I 那道题的变体 1 /* 2 * Complete the function below. 3 */ 4 5 static int is_score_possible(int score, int[] increments) { 6 A... 阅读全文
posted @ 2015-02-27 12:22 neverlandly 阅读(428) 评论(0) 推荐(0)
Twitter OA prepare: Rational Sum

摘要:In mathematics, a rational number is any number that can be expressed in the form of a fraction p/q , where p & q are two integers, and the denominato... 阅读全文
posted @ 2015-01-04 08:30 neverlandly 阅读(500) 评论(0) 推荐(0)
Twitter OA prepare: Flipping a bit

摘要:You are given a binary array with N elements: d[0], d[1], ... d[N - 1]. You can perform AT MOST one move on the array: choose any two integers [L, R],... 阅读全文
posted @ 2015-01-03 04:52 neverlandly 阅读(687) 评论(0) 推荐(0)

1 2 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3