SImple C Sort Solution(nlogn)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. Create a Structure f
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create a Structure for diff and profit to sort them based on difficulty in increaing order.\n2. then apply simple Binary Search to find the most profiting job for each worker\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint cmp(const void *a, const void *b) {\n    return *(int*)a - *(int*)b;\n}\n\ntypedef struct {\n    int difficulty;\n    int profit;\n} Job;\n\nint cmpJob(const void *a, const void *b) {\n    return ((Job*)a)->difficulty - ((Job*)b)->difficulty;\n}\n\nint maxProfitAssignment(int* diff, int n, int* profit, int n2, int* worker, int m) {\n    if (n != n2) return 0;\n    Job* jobs = (Job*)malloc(n * sizeof(Job));\n    for (int i = 0; i < n; i++) {\n        jobs[i].difficulty = diff[i];\n        jobs[i].profit = profit[i];\n    }\n    qsort(jobs, n, sizeof(Job), cmpJob);\n    qsort(worker, m, sizeof(int), cmp);\n    int* maxProfit = (int*)malloc(n * sizeof(int));\n    maxProfit[0] = jobs[0].profit;\n    for (int i = 1; i < n; i++) {\n        maxProfit[i] = jobs[i].profit > maxProfit[i - 1] ? jobs[i].profit : maxProfit[i - 1];\n    }\n    int totalProfit = 0;\n    int jobIndex = 0;\n    for (int i = 0; i < m; i++) {\n        while (jobIndex < n && worker[i] >= jobs[jobIndex].difficulty) {\n            jobIndex++;\n        }\n        if (jobIndex > 0) {\n            totalProfit += maxProfit[jobIndex - 1];\n        }\n    }\n    return totalProfit;\n}\n\n```
['C']