690.员工的重要性 添加测试函数
This commit is contained in:
parent
32457451e2
commit
1aff9a97cc
|
@ -8,9 +8,8 @@ struct Employee {
|
|||
|
||||
|
||||
impl Solution {
|
||||
/// 690.员工的重要性
|
||||
///
|
||||
/// [原题链接](https://leetcode-cn.com/problems/employee-importance/)
|
||||
//noinspection RsSelfConvention
|
||||
/// [690.员工的重要性](https://leetcode-cn.com/problems/employee-importance/)
|
||||
///
|
||||
/// 2021-05-01 08:43:10
|
||||
///
|
||||
|
@ -33,7 +32,7 @@ impl Solution {
|
|||
/// Related Topics 深度优先搜索 广度优先搜索 哈希表
|
||||
///
|
||||
/// 👍 146 👎 0
|
||||
fn get_importance(employees: Vec::<Employee>, id: i32) -> i32 {
|
||||
fn get_importance(employees: Vec<Employee>, id: i32) -> i32 {
|
||||
let mut map = std::collections::HashMap::<i32, Employee>::new();
|
||||
for e in employees {
|
||||
map.insert(e.id, e);
|
||||
|
@ -48,4 +47,17 @@ impl Solution {
|
|||
}
|
||||
dfs(id, &map)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::Solution;
|
||||
use crate::implements::q0690::Employee;
|
||||
|
||||
#[test]
|
||||
fn test_q0690() {
|
||||
assert_eq!(11, Solution::get_importance(vec![Employee { id: 1, importance: 5, subordinates: vec![2, 3] },
|
||||
Employee { id: 2, importance: 3, subordinates: vec![] },
|
||||
Employee { id: 3, importance: 3, subordinates: vec![] }], 1));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue