In html , I want to add more element in simple
way without createNode... So,
In javascript I wrote: document.getElementById("test").innerText = "
value=\"NS000018\">NS00018";
However, document.getElementById(elem).innerHTML =
public static void main(String args[]) {
int elem[]={-4,-3,-2,-1,2,3};
int elem2[] = {-5,-1,0,1,2,4,5};
checkZero(elem,4);
checkZero(elem2,2);
}
public static void checkZero(int[] elem, int n) {
//left, right
//left window size, right window size
int left = 0 ;
int right = elem.length-1;
int left_windowsize= n/2;
int right_windowsize= ... 阅读全帖
神奇的是
Old OJ 大集合通过
new OJ Runtime Error Last executed input: [0,2,3]
百思不得其解, code 如下。
public class Elem {
int index;
int step;
}
public boolean canJump(int[] A) {
// Start typing your Java solution below
// DO NOT write main() function
int len = A.length;
if (len == 0) return false;
if (len == 1) return true;
if (len == 2) return A[0] != 0;
Good idea. So the time complexity is O(N*logK)? I was studying DP and
tempted to solve problem by it. For this one, I'm thinking of another way to
solve it. Complexity is O(N*K):
Assuming we sort all the positions into a new array A, where each element A[
i] contains two members (position, word), 0<= position < N, 0<=word < K; the
elements are sorted by the position in ascending order.
Elem {
int position,
int word
}
看到了这个一个实现。也是把method用synchronized包起来: http://codereview.stackexchange.com/questions/3138/linkedhashma
public class LRUCache {
private final Map cacheMap;
public LRUCache(final int cacheSize) {
// true = use access order instead of insertion order.
this.cacheMap = new LinkedHashMap(cacheSize, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
// When ... 阅读全帖
有住Arlington Heights 或了解25 school district 的朋友说说下面四个小学那个比
较好,还有两个初中。
1. Patton Elem
2. Olive-Mary Stitt Elem
3. Windsor Elem
4. Dryden Elem
Middle School
Thomas Middle School
South Middle School
LEGB scoping rule
具体实践上,可以在 local 再引用一次 global
比如标准库里的小顶堆实现里的几句: https://hg.python.org/cpython/file/2.7/Lib/heapq.py#l215
_heappushpop = heappushpop
for elem in it:
_heappushpop(result, elem)
这里 heappushpop 是另外一个函数,在 global scope
如果直接放 for 循环里,每次都得先 lookup local scope,
再查 enclosed 和 global scope,就慢了。
所以在 local scope 里用 _heappushpop 来引用 global scope 的对象
for elem in it:
heappushpop(result, elem)
前面贴过好象
for each work, maintain a queue
scan
if(doc[i]==word[j])
queue[j].push[doc[i]];
if( queue[0]...queue[i] all have 1 elem && queue[j] has 2 elem)
update smallestWindowSize;
dequeue queue[0]...queue[i] until every queue has only 1 elem.
endif
end scan.
BST, O (n*(logW+k))
void printBST(multiset > &BST, int k){
int i=0;
multiset >::iterator it=BST.begin();
for(;i
cout<<(*it)<<",";
++it;
}
cout<
}
void topK_SlideWindow(vector &A, int w, int k){
//use BST tree to record w elems in the windows.
//update BST, add new elem into BST, and delete old elem.
assert(A.size()>=w&&k<=w);
multiset >BST;
for(int i=0;i
... 阅读全帖
我来加上API及初中信息:
Tom Matsumoto Elem.(982) -> Chaboya Middle (924) -> Evergreen Valley High (
839)
Carolyn Clark Elem.(943) -> Quimby Oaks Middle (852) -> Evergreen Valley
High (839)
我觉得初中还是需要900以上的,所以推荐属于 Tom Matsumoto Elem 的区域 (
Roughly South of Aborn, North of Yerba Buena, East of Ruby, to be sure,
check http://evergreen.ccsct.com/page.cfm?p=2455 )
Silver Creek High,可以比的,也不是North Valley的高中可以比的。
基本就搞定了。
There was a rezoning in 1995 in sunnyvale school district (move hollenbeck
elem to Vargas elem) and Cumberland elem benefitted a lot from that. That
94086 area used to be with cherry chase and Cumberland then.
I have a question of c++ programing habit,
I sometimes use list, map or other container to store user defined classes,
and use it later in member functions--say
std::list m_list;
When inserting a new element, I always have to fully create an element, then
call push_back or insert.
MyElement elem(1,2,"something"...);
m_list.push_back(elem);
And push_back would call copy constructor (I defined in MyElement class) to
duplicate the object.
After inserting, the elem itself is never used an... 阅读全帖
Hi,
A good friend just is running after school care in Northwood, Irvine. She
could pick up children from Northwood Elem, Brywood Elem, Santiago Elem and
Canyon View Elementery schools. She lives in Northwood and has opening for
new kids. Her house has a large living and study area, and she could help
homework and kids' piano practise. She is flexible to pick up kids from
school and can keep kids with her for late parents schedule.
She has limited opening now. Please pm me for contact and rate ... 阅读全帖
2个指针,l, r,分别指window的左右边. 开始l = r = 0,
(1) move r,直到这个window has all elems of B. record min window
(2) move l, until A[l] is in B.
(2) move l,直到这个one elem of B is not in the window.
(3) go to 2, if cur win length < min window length, update min window.
需要2n steps.
stop when r == n - 1.
3,1,5,7,3,5,2
l r 3
l r
l r
l r 3
l r
l r
l r 2
你这个有错误之处。我改一下啊。
2个指针,l, r,分别指window的左右边. 开始l = r = 0,
(1) keep increasing r,until window has all elems of B;
(2) while ( A[l] has duplicates in window || A[l] is not in B )
l++;
record this window as minwindow;
(3) do l++;
while ( A[l] has duplicates in window || A[l] is not in B );
(4) while ( window does not contain all elems of B )
r++;
(5) compare current window with minwindow and record the smaller one;
(6) if (r is not out of bound)
go to (3);
1. Solution 1. Since we anyway need to create a array of size nxk. all the
merge can be done in this new array. suppose the new array is array k+1:
copy array (0) to array k+1
for (array [1, k-1])
{
merge(array[i], array[k+1]);
}
Solution 2, use the following struct:
struct {
int value;
int arrayk;
int subIndex;
} Elem;
PriorityQueue minPQ(k);
for(int i = 0; i < k; i++)
{
minPQ.enqueue(Elem(array[i][0], i, 0));
}
4. Design a timing mechanism: when a packet is received, cancel the
timing;
otherwise, start timing until time out. Suppose each timing object has
different expiration period?
没看懂。
5. Given an integer, print out its square root
返回整数根?是最接近,还是小于且最接近?
6. An integer array of size m + 1 with m unique element, find the
duplicate
one
排序和散列两个方法,没更好的吧?
7. Given a function to read/write data from/to hard disk. Req(r/w, addr,
size, buffer), e.g.Read_write(read, 0, 5, …), Read_write(read, 5, 3, …).
This fun... 阅读全帖
这个可能犯规了……
import scala.collection.mutable.ArrayBuffer
def deepFlatten(list: Seq[Any]):ArrayBuffer[Int] = list match {
case Nil => ArrayBuffer()
case elem::rest => elem match {
case v: Int => v +=: deepFlatten(rest)
case l: Seq[Any] => deepFlatten(l) ++=: deepFlatten(rest)
}
}
class DeepIterator(list: Seq[Any]) {
val content = deepFlatten(list)
def hasNext = !content.isEmpty
def next = {
val item = content.head
content -= item
item
}
}
这个可能犯规了……
import scala.collection.mutable.ArrayBuffer
def deepFlatten(list: Seq[Any]):ArrayBuffer[Int] = list match {
case Nil => ArrayBuffer()
case elem::rest => elem match {
case v: Int => v +=: deepFlatten(rest)
case l: Seq[Any] => deepFlatten(l) ++=: deepFlatten(rest)
}
}
class DeepIterator(list: Seq[Any]) {
val content = deepFlatten(list)
def hasNext = !content.isEmpty
def next = {
val item = content.head
content -= item
item
}
}
type 'a elem = Single of 'a | Multi of ('a elem list);;
let rec flatten l =
match l with
| [] -> []
| hd :: tl -> match hd with
| Single x -> x :: flatten tl
| Multi x -> (flatten x) @ flatten tl;;
Top four elementary schools, top four middle schools in IL are Chicago
Magnet school: http://www.suntimes.com/news/education/1251847,illinois-school-report-cards-main-103108.article
Elementary Schools in Illinois
Rank School City
1 Decatur Classical* Chicago
2 Keller Gifted* Chicago
3 Lenart Gifted* Chicago
4 Edison Gifted* Chicago
5 King Gifted* Rockford
6 Lincoln Elem River Forest
7 Iles Elem* Springfield
8 Grove Avenue Barrington
9 Brook Forest Oak Brook
10 Nor
"The best public schools in Buckhead are in VERY expensive areas. Warren T.
Jackson Elementary serves West Buckhead from the zip 30327 with a couple of
hundred homes from 30342 and 30305 as well. The school has the IB program at
the elementary level and IMHO is the second best public school in the state
, next to Kittredge. Statistically it is ranked in the top five. Zip 30327
has a medium home value of $964,000 and each year homes get more expensive
in the area. Note that if you look up homes i... 阅读全帖