class Solution { /* 题目:提莫英雄有个被动,攻击其他英雄有2s中毒时间, 假入你被提莫在[1, 2, 3, 6]时刻攻击了,请问你中毒了几秒 输入:[1, 2, 3, 6] 输出:6 解析:中毒时间 1~5 6~8 */ public int findPoisoningTime(List<Integer> list){ int result = 0; for (int i = 0; i < list.size(); i++) { if (i == list.size() - 1 || list.get(i + 1) != list.get(i) + 1) { result += 2; } else { result += 1; } } return result; } }