Zheaoli / do-something-right

MIT License
37 stars 3 forks source link

2022-08-19 #334

Open Zheaoli opened 2 years ago

Zheaoli commented 2 years ago

2022-08-19

jingkecn commented 2 years ago
/*
 * @lc app=leetcode.cn id=1450 lang=csharp
 *
 * [1450] 在既定时间做作业的学生人数
 */

// @lc code=start
public class Solution {
    public int BusyStudent(int[] startTime, int[] endTime, int queryTime) {
        var count = startTime.Length;
        var ans = 0;
        for (var i = 0; i < count; i++)
        {
            if (queryTime < startTime[i] || queryTime > endTime[i])
            {
                continue;
            }

            ans++;
        }

        return ans;
    }
}
// @lc code=end

微信id: 我要成為 Dr. 🥬 来自 vscode 插件

SaraadKun commented 2 years ago

1450. 在既定时间做作业的学生人数

class Solution {
    public int busyStudent(int[] startTime, int[] endTime, int queryTime) {
        int ans = 0, n = startTime.length;
        for (int i = 0; i < n; i++) {
            if (startTime[i] <= queryTime && endTime[i] >= queryTime) {
                ans++;
            }
        }
        return ans;
    }
}

WeChat: Saraad

gongpeione commented 2 years ago
/*
 * @lc app=leetcode id=14 lang=typescript
 *
 * [14] Longest Common Prefix
 */

// @lc code=start
function longestCommonPrefix(strs: string[]): string {
    const num = Math.min(...strs.map(s => s.length));
    const common = [] as string[];

    for (let i = 0; i < num; i++) {
        const start = strs[0][i];
        if (strs.every(s => s[i] === start)) {
            common.push(start);
        } else {
            break;
        }
    }

    return common.join('');
};
// @lc code=end

微信id: 弘树 来自 vscode 插件

dreamhunter2333 commented 2 years ago
#include <istream>
#include <vector>
using namespace std;
/*
 * @lc app=leetcode.cn id=1450 lang=cpp
 *
 * [1450] 在既定时间做作业的学生人数
 */

// @lc code=start
class Solution
{
public:
    int busyStudent(vector<int> &startTime, vector<int> &endTime, int queryTime)
    {
        int res = 0;
        for (size_t i = 0; i < startTime.size(); i++)
        {
            if (startTime[i] <= queryTime && queryTime <= endTime[i])
                res++;
        }
        return res;
    }
};
// @lc code=end

微信id: 而我撑伞 来自 vscode 插件