-
Recent Posts
Recent Comments
Archives
Categories
Meta
Monthly Archives: February 2015
Replace all occurrence of the given pattern to ‘X’. For example, given that the pattern=”abc”, replace “abcdeffdfegabcabc” with “XdeffdfegX”. Note that multiple occurrences of abc’s that are contiguous will be replaced with only one ‘X’.
Posted in Uncategorized
Leave a comment
Leetcode: 3 sum and 4 sum problem
i: which skips duplicate numbers 4 sum with hashing public class Solution { public ArrayList<ArrayList> fourSum(ArrayList a, int b) { ArrayList<ArrayList> result = new ArrayList<ArrayList>(); HashSet<ArrayList> set = new HashSet<ArrayList>(); if(a == null || a.size() < 4) return result; Collections.sort(a); … Continue reading
Posted in interview
Leave a comment
Leetcode sqrt: Integer Square Root
// returning end because for example x = 2, initial s = 1, e = 1, mid = 1, mid*mide the loop terminates so end holds the floor of sqrt Without long:
Posted in interview
Leave a comment
Max Subarray: maximum sum subarray, maximum product subarray
//max product subarray
Posted in interview
Leave a comment
Leetcode: Longest Non-decreasing subsequence
//using DP easy one
Posted in interview
Leave a comment
Binary tree reconstruction from preOrder and inOrder/postOrder and inOrder traversal data
/* BTree from preorder traversal */ /* BTree from postorder traversal */
Posted in Uncategorized
Leave a comment