start jenkins continue integration server, more tutorial on Jenkins will put into Here.
I will compare it with Team Foundation Server 2012.
Total Accepted: 2068 Total Submissions: 7422
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
For example:
Given the following binary tree,
1 <--- / \ 2 3 <--- \ \ 5 4 <---
You should return [1, 3, 4]
.
[code]
[/code]
Without Configuration, PsExec could not execute successfully.
copy the following text and saved into .reg file in target machine:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
“LocalAccountTokenFilterPolicy”=dword:00000001
Then PsExec could run successfully.
Repeated DNA Sequences Total Accepted: 8816 Total Submissions: 47451 My Submissions Question Solution
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.
Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.
For example,
Given s = “AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT”,
Return:
[“AAAAACCCCC”, “CCCCCAAAAA”].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import java.util.*; public class RepeatedDNASequences { public static List<String> findRepeatedDnaSequences(String s) { ArrayList<String> result = new ArrayList<String>(); if(s== null || s.length() == 0) return result; HashMap<Character,Integer> map = new HashMap<Character,Integer>(); map.put('A',0); map.put('C',1); map.put('G',2); map.put('T',3); HashSet<Integer> hashSet = new HashSet<Integer>(); Set<Integer> unique = new HashSet<Integer>(); int temp = 0; for(int i=0;i<s.length();i++){ /*temp = 0; for(int j=0;j<10;j++){ temp = (temp<<2) + map.get(s.charAt(i+j)); }*/ if(i<9){ temp = (temp<<2) + map.get(s.charAt(i)); // System.out.println(temp); } else{ temp = (temp<<2) + map.get(s.charAt(i)); temp &= (1<<20) - 1; System.out.println(temp); if(hashSet.contains(temp) && !unique.contains(temp)){ result.add(s.substring(i-9,i+1)); unique.add(temp); } else { hashSet.add(temp); } } } return result; } public static void main(String[] args) { String s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"; System.out.println(findRepeatedDnaSequences(s)); } } |
At the beginning, iphone solution is too big to suite small screen.
so I can not see all button and image.
the way to get around it, run simulator. from menu on the top of monitor choose “Windows” -> “Scale” -> 50%
or Use ShortCut, CMD+1, CMD+2,CMD+3
although now simulator screen looks much smaller but at lease I could see all button and image for UI
add (setq x-select-enable-clipboard t) to .emacs
Then (set-mark-comment) and M-w
Total Accepted: 29154 Total Submissions: 100944
Given a string s consists of upper/lower-case alphabets and empty space characters ' '
, return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
For example,
Given s = "Hello World"
,
return 5
.
https://oj.leetcode.com/problems/length-of-last-word/
Solution: see the comment in the code , writed in Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public static int lengthOfLastWord(String s) { if(s.length() == 0) return 0; // input may be "" int result = -1; int skipEmpty = 0; // skip empty string at the end of input string s for(int i= s.length() - 1;i>=0;i--) { if(s.charAt(i) == ' ') continue; else { skipEmpty = i; break; } } //Start to Calculate for(int i= skipEmpty;i>=0;i--) { if(s.charAt(i) != ' ') continue; else { result = i; break; } } return skipEmpty - result; } |
By default, Emacs just provide some simple auto complete. For example, Alt + /, it will invoke ‘dabbrev-expand’.
and ‘dabbrev-expand’ is to find and complete what you enter once it find match words in all ‘buffer’ opened.
xrefactory is excellent commerce plugin for emacs, xrefactory is free for C/Java.
Here is how to enable xrefactory in emacs.
http://www.xref.sk/xrefactory/downloads/1.6.10/xrefactory-1.6.10-src.tgz
uncompress the tgz file,tar zxvf xrefactory-1.6.10-src.tgz
go into folder ‘xref-any’ , type command ‘make’, it will compile and finish to get ‘xref’
In .emacs file, add following code (replace ‘path/to’ to the path you want)
(add-to-list ‘load-path “/path/to/xref-any/env/emacs”)
(add-to-list ‘exec-path “/path/to/xref-any/src”)
(load “xrefactory”)
;;(load “/path/to/env/emacs/xrefactory.el”)
run ‘M-x eval-current-buffer’ , Now you could use xrefactory , Press ‘F8’ key to call ‘xref-completion’
xref is very powerfull, but we still has some other tools such as ‘gccsense, gtags’, I will add these two later on.
when running upgrade to mac os yosemite, I find two process mds and mdworker use almost 100% in my core 2 duo macbook pro 13.
sudo mdutil -a -i off
Then cpu usage drop down to 0%.
To Enable them.
sudo mdutil -a -i on
// 这些函数算是比较基本的了,看看就明白
static inline int is_space(int ch)
{
return ch == ‘ ‘ || ch == ‘\t’ || ch == ‘\v’ || ch == ‘\f’ || ch == ‘\r’;
}
static inline int isid(int c)
{
return (c >= ‘a’ && c <= ‘z’) || (c >= ‘A’ && c <= ‘Z’) || c == ‘_’;
}
static inline int isnum(int c)
{
return c >= ‘0’ && c <= ‘9’;
}
static inline int isoct(int c)
{
return c >= ‘0’ && c <= ‘7’;
}
static inline int toup(int c)
{
return (c >= ‘a’ && c <= ‘z’) ? c – ‘a’ + ‘A’ : c;
}
preprocess_new () at tccpp.c:3199
初始化isidnum表
/* init isid table */
for(i=CH_EOF;i<256;i++)
isidnum_table[i-CH_EOF] = isid(i) || isnum(i);
// 该函数剩下几行把tcc的关键字插入 ptable (代码如下)
[code]
static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
{
TokenSym *ts, **ptable;
[/code]
[code]
//在头文件tcctok.h定义了tcc的关键字
static const char tcc_keywords[] =
#define DEF(id, str) str “\0”
#include “tcctok.h”
#undef DEF
;
[/code]
ST_FUNC TokenSym *tok_alloc(const char *str, int len)