原创 尋找字典中變位詞

問題 Given a dictionary of English words, return the set of all words grouped into subsets of words that all anagrams of

原创 如何使用堆棧實現隊列

Problem How to use two stacks to implement a queue Solution It is simple, just serialize two stacks  #include <iostrea

原创 翻轉字符串

Problem Check if a string is a rotation of another. For example: Hello and loHel are a rotation pair. Tony and Julia ar

原创 Find pairs equal zero -- Paypal

Problem Given 2 equal-length arrays of integers, find pairs, one from each array, that sum to 0.  -- note that one wri

原创 計算兩個字符串鏈表中的共同數據項,需要考慮重複選項的情況

Problem /* // Given two lists of strings build a new list that has all strings that appear in both the original lists.

原创 Print an array in spiral order -- Microsoft

Problem Given an mxn matrix, design a function that will print out the contents of the matrix in spiral format.  Spir

原创 Compute the maximum of two integers without if-else

using System; namespace JamesChen {     class Program     {         static int MaximumWithoutIf(int a, int b)      

原创 Swap kth element from the beginning and kth element from the end of linked list -- Amazon

 轉載自:https://sites.google.com/site/spaceofjameschen/home Problem Swap kth element from the beginning and kth element fr

原创 Print the numbers of form 2^i.5^j in increasing order -- Google

Problem Print the numbers of form 2^i.5^j in increasing order. For eg:  1, 2, 4, 5, 8, 10, 16, 20 Solution usi

原创 Find the maximum contiguous subsequence product -- InMobi

Problem Suppose you have an array of +ve numbers, -ve numbers and zeroes. Devise an algorithm to find the maximum conti

原创 查找數組中的缺失的2個數字

Problem Two numbers are missing from the first hundred numbers. They are NOT sorted. How to find them?  You can't sort.

原创 Detect whether two rectangles have common area or not -- Amazon

Problem Write a function to check if two rectangles defined as below, have common area or not.  The functions take

原创 將矩陣中含零的行和列置零

Problem If an element in an MxN matrix is 0, set its entire row and column to 0 Solution public class ZeroRowAndCol{

原创 字符串中的字符是否都是唯一的,未重複的

Problem Determine if a string has all unique characters. Solution public class UniqueCharInString{ public static vo

原创 內存分配中的對齊操作

Problem Memory operation with alignment Solution #include <iostream> using namespace std; int aligned_malloc(void