Zun Wang personal blog


  • Home

  • Tags

  • Categories

  • Archives

  • Search

LeetCode Tree Problems Summary

Posted on 2018-10-01 | Post modified: 2018-10-13 | In code
  • This is a summary of Tree Problems in LeetCode. Including the thought, code and some tricks.

Preorder

100. Same Tree

  • 可套用模板,双pre
    1
    2
    3
    4
    5
    6
    public boolean isSameTree(TreeNode p, TreeNode q) {
    if(p == null && q == null) return true;
    if(p == null || q == null) return false;
    if(p.val != q.val) return false;
    return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
Read more »

subSet Problems

Posted on 2018-09-30 | Post modified: 2018-10-03 | In code

大佬总结链接)
核心模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public List<List<Integer>> subsetsWithDup(int[] nums) {
List<List<Integer>> res = new ArrayList<>();
if (nums.length == 0) return res;
Arrays.sort(nums);//排序很关键
helper(res, new ArrayList<>(), nums, 0);
return res;
}

//有些需要start,有些不需要
private void backtrack(List<List<Integer>> res, List<Integer> temp, int[] nums, int start){
if (满足条件){
res.add(new ArrayList<>(temp));
return;
}
for (int i = start; i < nums.length; i++){//构建循环
//1. 是否去重
//2. temp添加元素
//3. 递归调用,param变化
//4. temp去掉末尾元素
}
}

Read more »

DBMS Review

Posted on 2018-10-02 | Post modified: 2018-10-02 | In DBMS

DBMS Exam2 Review

Structured Query Language (SQL) - Lecture 11

SQL is the standard relational database language and is related to the tuple relational calculus.
Standard enables easier switch to other DBMS, queries remain unchanged.

Main objectives

  • Create the database and relation structures
  • Perform basic data management tasks, such as insertion, modification, and deletion of data from the relations
  • Perform both simple and complex queries
  • Be portable between different DBMS
  • Perform the aforementioned services with minimal user efforts
  • Perform the aforementioned services with maximum performance
    Read more »

Zun Wang

3 posts
2 categories
3 tags
GitHub E-Mail
© 2018 Zun Wang
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4