Open Zheaoli opened 1 year ago
#
# @lc app=leetcode.cn id=1700 lang=python3
#
# [1700] 无法吃午餐的学生数量
#
from typing import List
# @lc code=start
class Solution:
def countStudents(self, students: List[int], sandwiches: List[int]) -> int:
unlike_count = 0
remain_count = len(students)
while sandwiches and unlike_count != remain_count:
if students[0] == sandwiches[0]:
students.pop(0)
sandwiches.pop(0)
unlike_count = 0
remain_count -= 1
continue
unlike_count += 1
students.append(students.pop(0))
return len(students)
# @lc code=end
微信id: 而我撑伞 来自 vscode 插件
/*
* @lc app=leetcode id=119 lang=typescript
*
* [119] Pascal's Triangle II
*/
// @lc code=start
function getRow(rowIndex: number): number[] {
const ans = [1];
for (let i = 1; i <= rowIndex; i++) {
// from end to start
// make sure that prev value is not override before it being used
for (let j = i; j > 0; j--) {
ans[j] = (ans[j - 1] || 1) + (ans[j] || 0);
}
}
return ans;
};
// @lc code=end
微信id: 弘树 来自 vscode 插件
2022-10-20