-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjiujiu.php
84 lines (70 loc) · 1.68 KB
/
jiujiu.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* 九九乘法表
* 1*1=1
* 2*1=1,2*2=4
* 3*1=3,3*2=6,3*3=9......
*/
/*for($i = 1; $i <= 9; $i++){
for($j = 1; $j <= $i; $j++){
echo '<span style="display: inline-block;width: 85px;margin-bottom:5px;">'.$j.' * '.$i.' = '.$j * $i.'</span>';
}
echo "<br/>";
}*/
/**
* 无重复字符串的最长子串
*/
$string = 'bbbcbbbbba';
/*echo $string[4];
echo '<br/>';*/
/*public class Solution {
public int lengthOfLongestSubstring(String s) {
int n = s.length();
int ans = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j <= n; j++)
if (allUnique(s, i, j)) ans = Math.max(ans, j - i);
return ans;
}
public boolean allUnique(String s, int start, int end) {
Set<Character> set = new HashSet<>();
for (int i = start; i < end; i++) {
Character ch = s.charAt(i);
if (set.contains(ch)) return false;
set.add(ch);
}
return true;
}
}*/
/*$max='';
while($string!=''){
$i=0;
while($i<strlen($string) && $string[$i]==$string[0]) $i++;
if ($i>strlen($max)){
$max=substr($string,0,$i);
}
$string=substr($string,$i);
}
echo $max;*/
$string = 'cbbbcbbbbbae';
echo strlen($string);
function string_length($string){
if ($string == ''){
return 0;
}
$len = 1;$strs = $string[0];
for($i = 0; $i < strlen($string); $i++){
for($j = $i+1; $j < strlen($string); $j++){
if($string[$i] == $string[$j] || strpos($strs, $string[$j]) !== false){
break;
}
$strs .= $string[$j];
$len++;
}
}
return $len;
}
$res = string_length($string);
echo '<pre>';
var_dump($res);
echo '</pre>';