摘要: public bool IsPalindrome(int x) { // Special cases: // As discussed above, when x revertedNumber) { revertedNumber = revertedNumber * 10 + x % 10; x /= 10... 阅读全文
posted @ 2018-12-08 01:35 apanda009 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Implement a Queue with pop and push operations using concurrency coding. package com.company; import java.util.*; import java.util.concurrent.locks.*; class BQueue { Condition isFullCo... 阅读全文
posted @ 2018-10-24 07:03 apanda009 阅读(409) 评论(0) 推荐(0) 编辑
摘要: private static void remove(String s) { if (s == null || s.length() == 0) { return; } StringBuilder sb = new StringBuilder(); Stack st1 = new Stack(); ... 阅读全文
posted @ 2018-10-02 02:23 apanda009 阅读(93) 评论(0) 推荐(0) 编辑
摘要: // Returns maximum sum of a subarray with at-least // k elements. static int maxSumWithK(int a[], int n, int k) { // maxSum[i] is going to store maximum sum // ti... 阅读全文
posted @ 2018-09-20 05:00 apanda009 阅读(126) 评论(0) 推荐(0) 编辑
摘要: /*Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means 阅读全文
posted @ 2018-07-09 00:28 apanda009 阅读(87) 评论(0) 推荐(0) 编辑
摘要: Design and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put. get(key) - Get t 阅读全文
posted @ 2018-07-05 03:10 apanda009 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators a 阅读全文
posted @ 2017-12-28 05:11 apanda009 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Use buckets to record the last position of digit 0 ~ 9 in this num. Loop through the num array from left to right. For each position, we check whether 阅读全文
posted @ 2017-12-20 13:04 apanda009 阅读(133) 评论(0) 推荐(0) 编辑
摘要: The sample input is very confusing when time t has mixed meaning of beginning of time t for start and end of time t for end We can increase all end ti 阅读全文
posted @ 2017-12-20 12:53 apanda009 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 注意这道题:Must be exactly one distance apart. Not the same. 另外FB面经有一道比较狠的这个题的变形: 这题就是one edit distance的变形题,难点在于给的Iterator,事先不知道两个file的长度,也不允许用extra space( 阅读全文
posted @ 2017-12-20 12:08 apanda009 阅读(153) 评论(0) 推荐(0) 编辑