-
-
Notifications
You must be signed in to change notification settings - Fork 155
Docs: Added Solutions to Leetcode 621 #1422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Added Solutions to Leetcode 621 #1422
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, @shreyash3087! 🎉 Thank you for submitting your pull request to CodeHarborHub. We appreciate your contribution and enthusiasm! Our team will review it soon. If you have any questions or need further assistance, feel free to reach out. Thanks for contributing!
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update code based on suggestions
|
||
### Constraints | ||
|
||
- $1 <= tasks.length <= 10^4$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace $1 <= tasks.length <= 10^4$
to $1 \leq \text{tasks.length} \leq 10^4$
|
||
- $1 <= tasks.length <= 10^4$ | ||
- `tasks[i]` is an uppercase English letter. | ||
- $0 <= n <= 100$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace $0 <= n <= 100$
to $0 \leq n \leq 100$
|
||
### Space Complexity: $O(1)$ | ||
|
||
> **Reason**: The space complexity is mainly determined by the frequency array and the priority queue. The frequency array has a constant size of 26, and the priority queue can have a maximum size of 26 when all distinct tasks are present. Therefore, the overall space complexity is O(1) or O(26), which is considered constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace O(1)
to $O(1)$
, O(26)
to $O(26)$
|
||
> **Reason**: The space complexity is mainly determined by the frequency array and the priority queue. The frequency array has a constant size of 26, and the priority queue can have a maximum size of 26 when all distinct tasks are present. Therefore, the overall space complexity is O(1) or O(26), which is considered constant. | ||
|
||
### Approach #2 Filling the Slots and Sorting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace #2
to 2
> | ||
> - In Python, the sort method sorts a list using the Timsort algorithm which is a combination of Merge Sort and Insertion Sort and has O(N) additional space. | ||
> - In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(logN) for sorting two arrays. | ||
> - In C++, the sort() function is implemented as a hybrid of Quick Sort, Heap Sort, and Insertion Sort, with a worse-case space complexity of O(logN). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace v
to $O(logN)$
> | ||
> Note that some extra space is used when we sort arrays in place. The space complexity of the sorting algorithm depends on the programming language. | ||
> | ||
> - In Python, the sort method sorts a list using the Timsort algorithm which is a combination of Merge Sort and Insertion Sort and has O(N) additional space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace O(N)
to $O(N)$
|
||
> **Reason**: The frequency array has a size of 26. | ||
> | ||
> Note that some extra space is used when we sort arrays in place. The space complexity of the sorting algorithm depends on the programming language. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use note then try
:::note
// YOUR NOTES HERE
:::
Try this for best practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajay-dhangar Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Related Issue
Closes #1379
Description
This PR adds the solution to leetcode problem 6621 - (Task Scheduler)
Type of PR
Screenshots / Videos (if applicable)
Checklist
Additional Context
N/A