建议安装油猴插件
效果如下
C++
public class Solution {
public int lengthOfLongestSubstring(String s) {
int n = s.length();
Set<Character> set = new HashSet<>();
int ans = 0, i = 0, j = 0;
while (i < n && j < n) {
// try to extend the range [i, j]
if (!set.contains(s.charAt(j))){
set.add(s.charAt(j++));
ans = Math.max(ans, j - i);
}
else {
set.remove(s.charAt(i++));
}
}
return ans;
}
}
java
//if str is null,there is invalid parameters
if(str == null){
throw new IlleagalArgumentException("invalid parameters");
//if length of the string is 0 or 1,there is no duplicate character and return to true
if(str.length() == 0 || str.length() == 1){
return true;
}
//create HashTable,put the string into HashTable
HashSet<Character>hs = new HashSet<Character>();
for(int i = 0; i < str.length(); i++){
if(hs.contains(str.charAt(i))){
return false;//The same characters are shown in the hash table,so that there are repeated characters.
}
hs.add(str.charAt(i));
}
return true;
if(str == null){
throw new IllegalArgumentExceptiono("invalid parameters");
}
//if the length of str is 0 or 1,so that there is no repeated characters,return true
if(str.length() == 0 || str.length() == 1){
return true;
}
//create HashTable,put the string to HashTable
HashSet<Charagcter> hs = new HashSet<Character>();
for(int i = 0;i <str.length(); i++){
if(hs.contains(sts.charAt(i))){
return false;//There is same character in HashSet,so that there are repeated characters
}
hs.add(str.charAt(i));
}
return true;
信息熵模型 | Shannon's Entropy Model
Shannon's Entropy model
decision Tree set up branch
<font colort="blue size="6">uncertainty
The First Column | The Second Column |
---|---|
Batch_size | 批尺寸 |
epoch | when a full dataset cross over neural networks and return a time,the full process named a epoch |
epoch | as the number of epoch increasing,the number of updates of weights in neural netwoks increase,and the curve changes from under-fitting to over-fitting. |
iteration | iteration = \(iteration = /frac{the sample size in epoch}{the sample size in batch(batch size)}\) |
epoch | there is a dataset of 2000 training samples.The 2000 samples are devided into 500 sizes of batch,so it takes 4 iterations to complete a epoch. |
normal distribution | \(f{1}{\sqrt{2\pi}\sigma}exp{-\frac{(x-mu)^2}{2\sigma^2}}\) |
normal distribution | \(f(x;\mu;\sigma)=\frac{1}{\sqrt{2\pi}\sigma}exp{-\frac{x-\mu)^2}{2\sigma^2}}\) |
epoch | needing 4 iteration to finish a epoch |
information entropy | the information entropy of a thing is the smallest space you need to store it on your hard disk |
stochastic | 随机的 |
optimum | 最适宜的 |
ans | lengthOfLongSubString |
Set | Randomness , no subscript , no duplicate element |
Set<Character> = new HashSet<>();
set.add("c");
set.add("b");
set.add("d");
set.add("a");
set.add("a");
System.out.println(set);
- result
- [a,b,c,d] //based on the results,we can see it is nondisordered and non repeatability
Hash<Character> hashSet = new HashSet<>();
hashSet.add("a");
hashSet("b");
hashSet("d");
hashSet("d");
Systeim.out.println(hashSet);
- result
- [a,b,d]
TreeSet<Integer> treeSet = new TreeSet<>();
treeSet.add(10);
treeSet.add(8);
treeSet.add(15);
treeSet.add(11);
treeSet.add(8);
System.out.println(treeSet);
- result
- [8,10,11,15] //treesetsort sorts and delete repeated elements
public class Solution{
public int lengthOfLongestSubString(String s){
int n = s.length();
int ans = 0;
for(i = 1,i < n; i++){
for(j = i+1; i < n; i++){
if (allUnique(s,i,j)) ans = Math.max(ans, j-i); //java.lang.Math.max(parameter_1 , parameter_2) parameter is int , double , float ,long
//allUnique() is public boolean allUnique()
}
}
}
return ans;
}
public boolean allUnique(String s, int start, int end) {
Set<Character> set = new HashSet<>(); //set : out of order(inconsistent access sequence),no index and unrepeatable.
//HahSet and TreeSet : HashSet'API is Hash Algorithms,TreeSet'API is binary tree
for(int i = start, i < end; i++) {
Character ch = s.charAt(i);
if(set.contain(ch)){
return false;
}
set.add(ch);
}
return true;
}
char = 'a';
Character ch1 = ch; //automatix packageing
Character c = new Character(a);
char c1 = c; //automatic unpakaging
int t= 10;
Integer t1 = t; //automatic pakaging
Integer t = new Integer(10);
int t1 = t; //automatic unpacking
public class Text{
public static void main(String args[]) {
String s = "www.runoob.com"
char result = s.charAt[8];
System.out println(result);
}
}
iteration is the times that batch finish one epoch
iteration is the times that batch finish one epoch
AP measures the quality of learned models in each category,and mAP measures the quality of learned modules in all categorie.After obtaining AP,the calculation of mAP is to take the average value of all mAP.
AP衡量的是学出来的模型在每个类别上的好坏,mAP衡量的是学出的模型在所有类别上的好坏,得到AP后mAP的计算就变得很简单了,就是取所有AP的平均值。
暴力法
publicclassSolution {
public int lengthOfLongestSubstring(String s) {
int n s.length;
int ans = 0;
for (i = 0; i < n; i++)
for (int j = i+1; j <= n; j++)
if (allUnique(s, i, j) ans = Math.max(ans, j - i); //i = 0, j = 1, allUnique(asd, 0, 1), ans = Math.max(0, 1 - 0), return 1; allUnique(asd, 0, 1), Set<Character> = new HashSet<>(); for (int i = 0; i < 1; i++) {Character ch = "asd".charAt(0), if (set.contain("a")) return false; set.add("a"); } retrurn true;
public boolean allUnique(String s, int start, int end) {
Set<Character> set= new HashSet<>();
for (i = start; i < end; i++){
Character ch = s.charAt(i);
if (set.contains(ch)) return false;
set.add(ch);
}
return true;
}
}