本周主要是做了一道关于链表相关操作的算法题目,数据库查询的题目,阅读了一篇关于 UI 自动化测试相关的英文文章,仔细学习了下 ConstraintLayout 相关的资料,后期要仔细总结一下相关的知识。
Algorithm
题目描述
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Example:
> Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
> Output: 7 -> 0 -> 8
> Explanation: 342 + 465 = 807.
>
题目相对比较简单,只是简单的链表操作。
Java
public ListNode addTwoNumbers(ListNode l1, ListNode l2) { |
Python
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: |
Runtime | Memory | Language |
---|---|---|
96ms | 13.4 MB | python |
2ms | 45.1 MB | java |
Database
181. Employees Earning More Than Their Managers
The
Employee
table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.
> +----+-------+--------+-----------+
> | Id | Name | Salary | ManagerId |
> +----+-------+--------+-----------+
> | 1 | Joe | 70000 | 3 |
> | 2 | Henry | 80000 | 4 |
> | 3 | Sam | 60000 | NULL |
> | 4 | Max | 90000 | NULL |
> +----+-------+--------+-----------+
>
Given the
Employee
table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.
+----------+
| Employee |
+----------+
| Joe |
+----------+
SELECT |
用到的方法就是是把表查询两遍,通过对比两个表的数据来确定最后的结果。
Review
本周主要学习了和 UI 测试相关的文章,文章中用到了 Espress、Mock 框架,对异步刷新 UI 数据的情况进行了测试方法的介绍。
Espresso UI Testing With Android Architecture Components
Tips
- python 取余
%
,这一点和java一样,取整数\\
,和java有所差异。 - 谷歌提供的新的布局
ConstraintLayout
,虽然可以减少布局层次,但是这个新布局measure过程相对传统布局来说较长,尤其是该布局用在ListItem的自定义 View 时,启动速度会较慢。
Share
一篇约束布局相关的文章:https://blog.csdn.net/guolin_blog/article/details/53122387