- 博客(20)
- 收藏
- 关注
原创 Leetcode606. Construct String from Binary Tree (C++)
Leetcode606. Construct String from Binary TreeLeetcode606. Construct String from Binary Tree递归方法可以一行完成,迭代方法比较麻烦。复杂度不佳,尚待提高。代码如下:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right
2020-05-11 16:22:26
183
原创 Leetcode590. N-ary Tree Postorder Traversal (C++)
Leetcode590. N-ary Tree Postorder TraversalLeetcode590. N-ary Tree Postorder Traversal和589类似,注意孩子节点的入栈顺序即可代码如下:/*// Definition for a Node.class Node {public: int val; vector<Node*> children; Node() {} Node(int _val) {
2020-05-10 15:52:29
305
原创 Leetcode589. N-ary Tree Preorder Traversal (C++)
Leetcode589. N-ary Tree Preorder TraversalLeetcode589. N-ary Tree Preorder Traversal递归与非递归(DFS):/*// Definition for a Node.class Node {public: int val; vector<Node*> children; Node() {} Node(int _val) { val = _val;
2020-05-10 14:59:55
235
原创 Leetcode617. Merge Two Binary Trees (C++)
Leetcode617. Merge Two Binary Trees简单题,迭代比递归复杂一点点代码如下:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeN
2020-05-10 14:18:51
197
原创 Leetcode面试题 04.02. 最小高度树 (C++)
Leetcode面试题 04.02. 最小高度树面试题 04.02. 最小高度树简单递归构造树,解答如下:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas
2020-05-10 11:06:28
207
原创 [SYSU][大二下] 高级编程技术HW Week-9 Lecture-2
Question在 Leetcode 下做一道题。Answer57. Insert Interval'''LeetCodeTopic: Array57. Insert IntervalDescription: Given a set of non-overlapping intervals, insert a new interval into the ...
2018-05-13 20:41:58
174
原创 [SYSU][大二下] 高级编程技术HW Week-9 Lecture-1
Question在 Leetcode 上做一道题Answer'''LeetCodeTopic: Array42. Trapping Rain WaterDescription: In a given array nums of positive integers, find three non-overlapping subarrays with ma...
2018-05-13 19:44:46
167
原创 [SYSU][大二下] 高级编程技术HW Week-8 Lecture-2
Question在 Leetcode 的 Topic: Array 下做一道题Answer407. Trapping Rain Water II'''LeetCodeTopic: Array407. Trapping Rain Water IIDescription: Given an m x n matrix of positive integers represen...
2018-05-04 12:34:12
258
原创 [SYSU][大二下] 高级编程技术HW Week-8 Lecture-1
Question在 Leetcode 的 Topic: Array 下做一道题Answer42. Trapping Rain Water'''LeetCodeTopic: Array42. Trapping Rain Water: https://leetcode.com/problems/trapping-rain-waterDescription: Given n ...
2018-04-27 21:43:54
186
原创 [SYSU][大二下] 高级编程技术HW Week-6 Lecture-1
Question教材中课后的练习,11-1到11-3,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week6, Lecture1 HW by Duan 2018.04.16''''''11-1 城市和国家:'''import unittestfrom city_functions import get_formatte...
2018-04-16 17:53:41
203
原创 [SYSU][大二下] 高级编程技术HW Week-5 Lecture-2
Question教材中课后的练习,10-1到10-13,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week5, Lecture2 HW by Duan 2018.04.08 ''''''10-1 Python 学习笔记:'''filename = 'learning_python.txt'with open(filena...
2018-04-09 00:49:59
197
原创 [SYSU][大二下] 高级编程技术HW Week-5 Lecture-1
Question教材中课后的练习,9-1到9-15,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week5, Lecture1 HW by Duan 2018.04.02 ''' '''9-1 餐馆:'''class Restaurant(): def __init__(self, restaurant_...
2018-04-02 08:59:40
206
原创 [SYSU][大二下] 高级编程技术HW Week-4 Lecture-2
Question教材中课后的练习,8-1到8-17,选一些写到你的博客上Answer''' SYSU - [专选]高级编程技术 - Week4, Lecture2 HW by Duan 2018.03.28 ''' '''8-1 消息'''def display_message(): """打印一个句子,指出本章的学习内容""" print(...
2018-03-28 19:53:59
220
原创 [SYSU][大二下] 高级编程技术HW Week-4 Lecture-1
Question教材中课后的练习,7-1到7-10,选一些写到你的博客上Answer''' SYSU - [专选]高级编程技术 - Week4, Lecture1 HW by Duan 2018.03.26 ''' '''7-1 汽车租赁'''car = input('What kind of car would you like? ')print('L...
2018-03-26 20:34:27
178
原创 [SYSU][大二下] 高级编程技术HW Week-3 Lecture-2
Question教材中课后的练习,6-1到6-12,选一些写到你的博客上Answer''''' SYSU - [专选]高级编程技术 - Week3, Lecture2 HW by Duan 2018.03.22''' '''6-1 人'''info = {'first_name': 'Ying', 'last_name': 'Jiang', 'age': 37...
2018-03-22 13:11:35
160
原创 [SYSU][大二下] 高级编程技术HW Week-3 Lecture-1
Question教材中课后的练习,5-1到5-13,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week3, Lecture1 HW by Duan 2018.03.19 ''' '''5.3 外星人颜色#1'''alien_color = ['green', 'yellow', 'red']alien = 'red'print...
2018-03-19 18:02:12
216
原创 [SYSU][大二下] 高级编程技术HW Week-2 Lecture-2
Question教材中课后的练习,4-1到4-15,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week2, Lecture2 HW by Duan 2018.03.14 ''''''4-1 比萨:想出至少三种你喜欢的比萨,将其名称存储在一个列表中,再使用 for 循环将每种比萨的名称都打印出来。1. 修改这个 for 循环,使其打印包含...
2018-03-14 21:14:14
256
原创 [SYSU][大二下] 高级编程技术HW Week-2 Lecture-1
Question教材中课后的练习,3-1到3-11,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week2, Lecture1 HW by Duan 2018.03.12''' '''3-3 自己的列表:想想你喜欢的通勤方式,如骑摩托车或开汽车,并创建一个包含多种通勤方式的列表。根据该列表打印一系列有关这些通勤方式的宣言,如"I wo...
2018-03-12 23:11:46
305
原创 [SYSU][大二下] 高级编程技术HW Week-1 Lecture-2
Question教材中课后的练习,2-1到2-11,选一些写到你的博客上Answer'''SYSU - [专选]高级编程技术 - Week1, Lecture2 HWby Duan2018.03.08''''''2-1 简单消息:将一条消息存储到变量中,再将其打印出来。'''message = "This is a simple message!"print(message...
2018-03-08 13:13:42
323
原创 [SYSU][大二下] 高级编程技术HW Week-1 Lecture-1
Question浏览 Python 主页 ,在博客上写下你有哪些发现和收获。假设你已经称为一位 Python 编程高手,你打算实现怎样的程序?在博客上写下你的目标。Answer发现和收获:① 主页上不仅有面向 Python 初学者的 Beginner's Guide ,也有面向开发人员的 Developer's Guide ;② 有各种 Quiz 和 Exercise Questions(可在 B...
2018-03-05 22:39:11
192
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人