Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4eb2db7

Browse files
同步代码
1 parent 4cb7bd7 commit 4eb2db7

File tree

10 files changed

+1019
-1067
lines changed

10 files changed

+1019
-1067
lines changed

‎README.md‎

Lines changed: 947 additions & 945 deletions
Large diffs are not rendered by default.

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_119.java‎

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,17 @@
2424
* Could you optimize your algorithm to use only O(k) extra space?
2525
*/
2626
public class _119 {
27-
public staticList<Integer> getRow(int rowIndex) {
28-
List<Integer> list = new ArrayList<Integer>();
27+
public List<Integer> getRow(int rowIndex) {
28+
List<Integer> ans = new ArrayList<>();
2929
for (int i = 0; i < rowIndex + 1; i++) {
3030
/**
3131
* Every iteration set 1 at a position that index is 0
3232
*/
33-
list.add(0, 1);
34-
for (int j = 1; j < list.size() - 1; j++) {
35-
list.set(j, list.get(j) + list.get(j + 1));
33+
ans.add(0, 1);
34+
for (int j = 1; j < ans.size() - 1; j++) {
35+
ans.set(j, ans.get(j) + ans.get(j + 1));
3636
}
3737
}
38-
return list;
39-
}
40-
41-
public static List<Integer> getRow2(int rowIndex) {
42-
Integer[] rowArr = new Integer[rowIndex + 1];
43-
Arrays.fill(rowArr, 0);
44-
rowArr[0] = 1;
45-
for (int i = 1; i <= rowIndex; i++) {
46-
for (int j = i; j > 0; j--) {
47-
rowArr[j] = rowArr[j] + rowArr[j - 1];
48-
}
49-
}
50-
return Arrays.asList(rowArr);
51-
}
52-
53-
public static void main(String[] args) {
54-
System.out.println(_119.getRow(3));
55-
System.out.println(_119.getRow2(3));
38+
return ans;
5639
}
5740
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_189.java‎

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
*/
3939
public class _189 {
4040
public void rotate(int[] nums, int k) {
41-
if (nums == null || nums.length < 2) {
42-
return;
43-
}
41+
if (nums == null || nums.length < 2) return;
4442
/**
4543
* When k is larger than nums.length,
4644
* mode operation can let us get smallest step number
@@ -71,7 +69,7 @@ public void rotate(int[] nums, int k) {
7169
System.out.println(Arrays.toString(nums));
7270
}
7371

74-
publicstatic void reverse(int[] nums, int start, int end) {
72+
private void reverse(int[] nums, int start, int end) {
7573
while (start < end) {
7674
int temp = nums[start];
7775
nums[start] = nums[end];
@@ -83,27 +81,4 @@ public static void reverse(int[] nums, int start, int end) {
8381
end--;
8482
}
8583
}
86-
87-
/**
88-
* Another method can be reference
89-
*
90-
* @param nums
91-
* @param k
92-
*/
93-
static void rotate2(int[] nums, int k) {
94-
if (nums.length == 0) {
95-
return;
96-
}
97-
int n = nums.length;
98-
while ((k %= n) > 0 && n > 1) {
99-
int range = n - k;
100-
for (int i = 1; i <= range; i++) {
101-
int val = nums[n - i];
102-
nums[n - i] = nums[n - i - k];
103-
nums[n - i - k] = val;
104-
}
105-
n = k;
106-
k = n - (range % k);
107-
}
108-
}
10984
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_209.java‎

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ public class _209 {
2525
* @param nums
2626
* @return
2727
*/
28-
public static int minSubArrayLen(int s, int[] nums) {
29-
if (nums == null || nums.length == 0) {
30-
return 0;
31-
}
28+
public int minSubArrayLen(int s, int[] nums) {
29+
if (nums == null || nums.length == 0) return 0;
3230
int headIndex = 0, tempIndex = 0, sum = 0, min = Integer.MAX_VALUE;
3331
/**
3432
* Iterate nums.length times
@@ -54,43 +52,4 @@ public static int minSubArrayLen(int s, int[] nums) {
5452
*/
5553
return min == Integer.MAX_VALUE ? 0 : min;
5654
}
57-
58-
/**
59-
* time complexity is O(n log n).
60-
*
61-
* @param s
62-
* @param nums
63-
* @return
64-
*/
65-
private static int solveNLogN(int s, int[] nums) {
66-
int[] sums = new int[nums.length + 1];
67-
for (int i = 1; i < sums.length; i++) {
68-
sums[i] = sums[i - 1] + nums[i - 1];
69-
}
70-
int minLen = Integer.MAX_VALUE;
71-
for (int i = 0; i < sums.length; i++) {
72-
int end = binarySearch(i + 1, sums.length - 1, sums[i] + s, sums);
73-
if (end == sums.length) break;
74-
if (end - i < minLen) minLen = end - i;
75-
}
76-
return minLen == Integer.MAX_VALUE ? 0 : minLen;
77-
}
78-
79-
private static int binarySearch(int low, int high, int key, int[] sums) {
80-
while (low <= high) {
81-
int middle = (low + high) / 2;
82-
if (sums[middle] >= key) {
83-
high = middle - 1;
84-
} else {
85-
low = middle + 1;
86-
}
87-
}
88-
return low;
89-
}
90-
91-
public static void main(String[] args) {
92-
int[] nums = {2, 3, 1, 2, 4, 3};
93-
System.out.println(_209.minSubArrayLen(7, nums));
94-
System.out.println(_209.solveNLogN(7, nums));
95-
}
9655
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_27.java‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* }
4646
*/
4747
public class _27 {
48-
public staticint removeElement(int[] nums, int val) {
48+
public int removeElement(int[] nums, int val) {
4949
int aimLength = 0;
5050
for (int i = 0; i < nums.length; i++) {
5151
/**
@@ -62,11 +62,4 @@ public static int removeElement(int[] nums, int val) {
6262
}
6363
return aimLength;
6464
}
65-
66-
public static void main(String[] args) {
67-
int[] nums = {3, 2, 2, 3, 3};
68-
int[] nums2 = {0, 1, 2, 2, 3, 0, 4, 2};
69-
System.out.println(_27.removeElement(nums, 3));
70-
System.out.println(_27.removeElement(nums2, 2));
71-
}
7265
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_485.java‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* The length of input array is a positive integer and will not exceed 10,000
2121
*/
2222
public class _485 {
23-
public staticint findMaxConsecutiveOnes(int[] nums) {
23+
public int findMaxConsecutiveOnes(int[] nums) {
2424
int maxConsecutiveLength = 0;
2525
int tempConsecutiveLength = 0;
2626
/**
@@ -44,11 +44,4 @@ public static int findMaxConsecutiveOnes(int[] nums) {
4444
}
4545
return maxConsecutiveLength;
4646
}
47-
48-
public static void main(String[] args) {
49-
int[] nums = {1, 1, 0, 1, 1, 1};
50-
int[] nums2 = {1, 0, 1, 1, 0, 1};
51-
System.out.println(_485.findMaxConsecutiveOnes(nums));
52-
System.out.println(_485.findMaxConsecutiveOnes(nums2));
53-
}
5447
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/array_and_string/_561.java‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
* All the integers in the array will be in the range of [-10000, 10000].
1919
*/
2020
public class _561 {
21-
public staticint arrayPairSum(int[] nums) {
21+
public int arrayPairSum(int[] nums) {
2222
/**
2323
* Use Arrays.sort() method let nums sort from small to big
24-
2524
*/
2625
Arrays.sort(nums);
2726

@@ -36,9 +35,4 @@ public static int arrayPairSum(int[] nums) {
3635
}
3736
return aimSum;
3837
}
39-
40-
public static void main(String[] args) {
41-
int[] nums = {1, 4, 3, 2};
42-
System.out.println(_561.arrayPairSum(nums));
43-
}
4438
}

‎codes/java/leetcodes/src/main/java/com/hit/basmath/learn/binary_search/_167.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* <p>
66
* Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
77
* <p>
8-
* The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.
8+
* The function twoSum should return anss of the two numbers such that they add up to the target, where index1 must be less than index2.
99
* <p>
1010
* Note:
1111
* <p>
@@ -21,21 +21,21 @@
2121
*/
2222
public class _167 {
2323
public int[] twoSum(int[] numbers, int target) {
24-
int[] indice = new int[2];
25-
if (numbers == null || numbers.length < 2) return indice;
24+
int[] ans = new int[2];
25+
if (numbers == null || numbers.length < 2) return ans;
2626
int left = 0, right = numbers.length - 1;
2727
while (left < right) {
2828
int twoSumValue = numbers[left] + numbers[right];
2929
if (twoSumValue == target) {
30-
indice[0] = left + 1;
31-
indice[1] = right + 1;
30+
ans[0] = left + 1;
31+
ans[1] = right + 1;
3232
break;
3333
} else if (twoSumValue > target) {
3434
right--;
3535
} else {
3636
left++;
3737
}
3838
}
39-
return indice;
39+
return ans;
4040
}
4141
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.hit;
2+
3+
/**
4+
* Created by guobin on 2020年3月22日.
5+
*/
6+
public class SwitchString {
7+
8+
public static void main(String[] args) {
9+
10+
method(null);
11+
12+
}
13+
14+
public static void method(String param) {
15+
16+
switch (param) {
17+
18+
// 肯定不是进入这里
19+
20+
case "sth":
21+
22+
System.out.println("it's sth");
23+
24+
break;
25+
26+
// 也不是进入这里
27+
28+
case "null":
29+
30+
System.out.println("it's null");
31+
32+
break;
33+
34+
// 也不是进入这里
35+
36+
default:
37+
38+
System.out.println("default");
39+
40+
}
41+
42+
}
43+
44+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@startuml
2+
TutorTaskProcessTimer.process -> processTutorTask: 调用服务层方法,处理状态为进行中的任务
3+
processTutorTask -> getTaskStatus: 从U群获取任务列表及对应的状态
4+
getTaskStatus -> processTutorTask: 返回任务状态列表
5+
processTutorTask -> pushTaskStatus: 推送任务状态
6+
pushTaskStatus -> sendMessage: 根据任务类型发送指定信息
7+
processTutorTask -> pushContact: 仅处理备注类型消息
8+
processTutorTask -> batchUpdateStatus: 批量更新任务状态
9+
@enduml

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /