最近在学设计模式,学到创建型模式的时候,碰到单例模式(或叫单件模式),现在整理一下笔记。 在《Design Patterns:Elements of Resuable Object-Oriented Software》中的定义是:Ensurea class only has one insta...
题目:
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn’t matter what you leave beyond the new length. 这道题比...
分类:
其他好文 时间:
2015-03-18 23:25:51
阅读次数:
290
//通过id查找多个元素function getElements(/*ids...*/){ var elements = {}; for(var i=0; i parent.childNodes.length) throw new Error('invalid index'); else if( n...
分类:
编程语言 时间:
2015-03-18 22:54:47
阅读次数:
213
问题来源:https://leetcode.com/problems/rotate-array//**
*
*
* ClassName RotateArray
*
*
* Description Rotate an array of n elements to the right by k steps.
*
* For example, with n =...
分类:
其他好文 时间:
2015-03-18 20:38:18
阅读次数:
108
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements.You may...
分类:
其他好文 时间:
2015-03-18 09:04:03
阅读次数:
154
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],...
分类:
其他好文 时间:
2015-03-17 23:08:37
阅读次数:
187
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:...
分类:
其他好文 时间:
2015-03-17 17:32:13
阅读次数:
139
Recover Binary Search Tree问题:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A ...
分类:
其他好文 时间:
2015-03-17 15:41:16
阅读次数:
139
DescriptionYou've got arraya[1],?a[2],?...,?a[n], consisting ofnintegers. Count the number of ways to split all the elements of the array into three c...
分类:
其他好文 时间:
2015-03-17 14:02:57
阅读次数:
128
Leetcode 78 SubsetGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The soluti...
分类:
其他好文 时间:
2015-03-17 11:47:34
阅读次数:
165