246 lines
5.4 KiB
Markdown
246 lines
5.4 KiB
Markdown
|
- Daily reflection [[Daily reflections]]
|
||
|
collapsed:: true
|
||
|
- What I've done
|
||
|
- What I've thought #thoughts
|
||
|
- 10:08
|
||
|
- logseq 比 obsidian 好用,计笔记成本低,而且好用,便携。
|
||
|
- Mood
|
||
|
- 10:09
|
||
|
- 平静且开心(lol)
|
||
|
-
|
||
|
- DONE [#C] 票在书包里
|
||
|
SCHEDULED: <2023-03-30 Thu>
|
||
|
-
|
||
|
- Todos:
|
||
|
- Personal
|
||
|
- DONE 重新浸洗袜子和内裤
|
||
|
SCHEDULED: <2023-03-28 Tue 13:00>
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 15:55:30]--[2023-03-28 Tue 15:55:31] => 00:00:01
|
||
|
:END:
|
||
|
- DONE 洗眼镜
|
||
|
SCHEDULED: <2023-03-28 Tue 13:00>
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 18:07:51]--[2023-03-28 Tue 22:41:19] => 04:33:28
|
||
|
:END:
|
||
|
- DONE Anki card for cloud collection 还不如没事多翻下书
|
||
|
SCHEDULED: <2023-04-01 Sat>
|
||
|
- School
|
||
|
- DONE 交选题
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 16:19:35]
|
||
|
CLOCK: [2023-03-28 Tue 16:19:40]--[2023-03-28 Tue 18:51:31] => 02:31:51
|
||
|
:END:
|
||
|
- DONE [#A] 复习 java
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 20:03:20]--[2023-03-29 Wed 22:25:48] => 26:22:28
|
||
|
:END:
|
||
|
- DONE 做题
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 20:03:29]--[2023-03-29 Wed 11:11:16] => 15:07:47
|
||
|
:END:
|
||
|
- DONE 练习题
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 20:03:51]--[2023-03-28 Tue 20:39:32] => 00:35:41
|
||
|
:END:
|
||
|
- DONE 往年题
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 20:03:50]--[2023-03-28 Tue 22:41:14] => 02:37:24
|
||
|
:END:
|
||
|
- DONE Leetcode
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-29 Wed 11:19:02]
|
||
|
CLOCK: [2023-03-29 Wed 11:19:04]--[2023-03-29 Wed 16:52:09] => 05:33:05
|
||
|
:END:
|
||
|
- DONE 看 ppt
|
||
|
:LOGBOOK:
|
||
|
CLOCK: [2023-03-28 Tue 20:03:30]--[2023-03-29 Wed 11:18:53] => 15:15:23
|
||
|
:END:
|
||
|
-
|
||
|
- OJ problem notes
|
||
|
- Name:
|
||
|
- Contains Duplicate
|
||
|
- Times:
|
||
|
- Completion time: 14:31
|
||
|
- Revisions:
|
||
|
- Tags:
|
||
|
- Data structures: #hash_table
|
||
|
- Difficulty: #difficulty_easy
|
||
|
- Platforms: #leetcode
|
||
|
- Links:
|
||
|
- [link to the problem](https://leetcode.com/problems/contains-duplicate/description/)
|
||
|
- Problem:
|
||
|
- Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct.
|
||
|
- Examples:
|
||
|
- ```
|
||
|
|
||
|
|
||
|
Example 1:
|
||
|
|
||
|
Input: nums = [1,2,3,1]
|
||
|
Output: true
|
||
|
|
||
|
Example 2:
|
||
|
|
||
|
Input: nums = [1,2,3,4]
|
||
|
Output: false
|
||
|
|
||
|
Example 3:
|
||
|
|
||
|
Input: nums = [1,1,1,3,3,4,3,2,4,2]
|
||
|
Output: true
|
||
|
|
||
|
```
|
||
|
- Constraints:
|
||
|
- `1 <= nums.length <= 105`
|
||
|
- `-109 <= nums[i] <= 109`
|
||
|
- Thoughts:
|
||
|
- Very simple hash map problem
|
||
|
- Solution:
|
||
|
- ```java
|
||
|
class Solution {
|
||
|
public boolean containsDuplicate(int[] nums) {
|
||
|
Set <Integer> set = new HashSet<Integer>();
|
||
|
for (int i : nums) {
|
||
|
if (set.contains(i)) {
|
||
|
return true;
|
||
|
} else {
|
||
|
set.add(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
-
|
||
|
-
|
||
|
-
|
||
|
- Java 练习题 1 #to_be_deleted
|
||
|
collapsed:: true
|
||
|
- Q1
|
||
|
- `less than 10`
|
||
|
- Q2
|
||
|
- `greater than 10`
|
||
|
- Q3
|
||
|
- `yes`
|
||
|
- Q4
|
||
|
- ```
|
||
|
zero
|
||
|
one
|
||
|
none
|
||
|
```
|
||
|
- Q5
|
||
|
- ```
|
||
|
zero
|
||
|
one
|
||
|
none
|
||
|
one
|
||
|
none
|
||
|
none
|
||
|
```
|
||
|
- Q6
|
||
|
- ```
|
||
|
zero
|
||
|
none
|
||
|
one
|
||
|
zero
|
||
|
none
|
||
|
none
|
||
|
```
|
||
|
- Q7
|
||
|
- ```java
|
||
|
int sum;
|
||
|
for (int i = 1; i <= 100; i++) {
|
||
|
sum += i;
|
||
|
}
|
||
|
System.out.println(sum);
|
||
|
```
|
||
|
- Q8
|
||
|
- ```java
|
||
|
for (int i = 1; i <= 3; i++) {
|
||
|
for (int j = 1; j <= 3; j++) {
|
||
|
System.out.print(i * j + " ");
|
||
|
}
|
||
|
System.out.println();
|
||
|
}
|
||
|
```
|
||
|
- Q9
|
||
|
- ```
|
||
|
9
|
||
|
8
|
||
|
true
|
||
|
```
|
||
|
- Q10
|
||
|
- ```java
|
||
|
int sum = 0;
|
||
|
for (int i = 1; i <= 99; i++) {
|
||
|
if (i % 3 == 0) {
|
||
|
sum += i;
|
||
|
}
|
||
|
}
|
||
|
System.out.println(sum);
|
||
|
```
|
||
|
- Q11 不想写
|
||
|
- Q12
|
||
|
- What does overloading mean?
|
||
|
- What does overloading do?
|
||
|
-
|
||
|
- java 练习题 2 [qmplus](https://qmplus.qmul.ac.uk/course/view.php?id=21582#section-8) #to_be_deleted
|
||
|
- Q1
|
||
|
- no.1 : not a array
|
||
|
no.2 : `int[] marks = new int[60]`
|
||
|
no.3 : `{'a', 'b', 'c'}`
|
||
|
no.4 : use ""
|
||
|
- Q2
|
||
|
- Compile error
|
||
|
- Q3
|
||
|
- `F[1]` is not initiated, it only has a null value
|
||
|
- Q4
|
||
|
- Array index out of bounds, f[2] is non-exist
|
||
|
- Q5
|
||
|
- compile error, local variable won't be initialized as default val
|
||
|
- Q6
|
||
|
- 36, 36.0
|
||
|
- Q7
|
||
|
- first one invalid
|
||
|
- Reason: wrong parameters
|
||
|
- third one invalid
|
||
|
- Reason: double->int can't be done implicitly, you have to use type casts
|
||
|
- Q8
|
||
|
- ```
|
||
|
vroom
|
||
|
truck 1
|
||
|
car 2
|
||
|
```
|
||
|
- Q9
|
||
|
- ```
|
||
|
vroomT
|
||
|
truck 1
|
||
|
car 1
|
||
|
```
|
||
|
- Q10
|
||
|
- 634.5
|
||
|
- Reason: calculated from left to right, all converted to String
|
||
|
- Q11
|
||
|
- F, only have access to package-private data
|
||
|
- F, no multi-inheritance for classes
|
||
|
- F, not required
|
||
|
- F, you can have one
|
||
|
- Q12
|
||
|
- b
|
||
|
- Q13
|
||
|
- false
|
||
|
- true
|
||
|
- true (reference stored in string constant pool)
|
||
|
- Q14
|
||
|
collapsed:: true
|
||
|
- 懒得写了
|
||
|
- Q15
|
||
|
collapsed:: true
|
||
|
- 懒得写
|
||
|
- Q16
|
||
|
- What is a abstract class?
|
||
|
- What is `toString` method?
|
||
|
- What does polymorphism mean?
|