Singleton is a most widely used design pattern. If a class has and only has one instance at every moment, we call this design as singleton. For exampl...
分类:
其他好文 时间:
2015-04-21 07:12:27
阅读次数:
223
Given an directed graph, a topological order of the graph nodes is defined as follow:For each directed edge A-->B in graph, A must before B in the ord...
分类:
其他好文 时间:
2015-04-16 13:48:58
阅读次数:
253
Write a method anagram(s,t) to decide if two strings are anagrams or not.ExampleGiven s="abcd", t="dcab", return trueO(N)time, O(1) space 1 public cla...
分类:
其他好文 时间:
2015-04-15 07:12:54
阅读次数:
104
Given a string and an offset, rotate string by offset. (rotate from left to right)ExampleGiven "abcdefg"for offset=0, return "abcdefg"for offset=1, re...
分类:
其他好文 时间:
2015-04-15 06:04:24
阅读次数:
124
1 class Solution { 2 public: 3 /** 4 * @param m: An integer m denotes the size of a backpack 5 * @param A: Given n items with size A[i]...
分类:
其他好文 时间:
2015-04-06 14:10:13
阅读次数:
109
1 class Solution { 2 public: 3 /** 4 * @param m: An integer m denotes the size of a backpack 5 * @param A & V: Given n items with size ...
分类:
其他好文 时间:
2015-04-06 14:08:59
阅读次数:
135
Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the l...
分类:
其他好文 时间:
2015-04-06 14:05:45
阅读次数:
116
Given an array of n objects with k different colors (numbered from 1 to k), sort them so that objects of the same color are adjacent, with the colors ...
分类:
其他好文 时间:
2015-04-06 10:08:40
阅读次数:
113
Given a string which contains only letters. Sort it by lower case first and upper case second.NoteIt's not necessary to keep the original order of low...
分类:
其他好文 时间:
2015-04-06 10:04:22
阅读次数:
225
Given 2*n + 2 numbers, every numbers occurs twice except two, find them.ExampleGiven [1,2,2,3,4,4,5,3] return 1 and 5ChallengeO(n) time, O(1) extra sp...
分类:
其他好文 时间:
2015-04-04 06:49:31
阅读次数:
165