-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Sidhant prs #1518
Sidhant prs #1518
Conversation
This pr is related to the issue - Dutch National Flag Implementation #1462 |
Hello @Sidhant-Gupta If you are picking problems for CP/DS-Algo Portals, please add their link. The above problem is from a LeetCode Problem. |
I've made the desired changes. Please review it. |
// | ||
// PROBLEM STATEMENT- https://leetcode.com/problems/sort-colors/ | ||
|
||
// Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. | ||
// Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. | ||
// In simpler words sort an array containing 0,1,2. | ||
|
||
// Solve the problem with a one-pass algorithm using only O(1) constant space? | ||
|
||
// TEST CASE- | ||
// Input: | ||
// n=6 | ||
// nums = [2,0,2,1,1,0] | ||
// Output: [0,0,1,1,2,2] | ||
|
||
// Input: | ||
// n=3 | ||
// nums = [2,0,1] | ||
// Output: [0,1,2] | ||
|
||
// The bruteforce approach - Sort the vector in nlogn time | ||
|
||
// ************************DUTCH_NATIONAL_FLAG ALGORITHM*********************************** |
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.
Shift the Comments above any lines of code
// TEST CASE- | ||
// Input: | ||
// n=6 | ||
// nums = [2,0,2,1,1,0] | ||
// Output: [0,0,1,1,2,2] | ||
|
||
// Input: | ||
// n=3 | ||
// nums = [2,0,1] | ||
// Output: [0,1,2] |
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.
Shift the sample I/O after the Code ends
med++; | ||
} | ||
else{ | ||
// swap(nums[med],nums[high]); |
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.
Remove any instances of commented lines of code. We prefer to have comments over the code but not commented code
|
||
// COMPLEXITY ANALYSIS- | ||
// Time= O(N) | ||
// space=O(1) |
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.
Add a line at the EOF
I've made all the requested changes. Kindly review @HarshCasper |
Have you read the [Contributing Guidelines on Pull Requests]
Yes,I have read.
(Write your answer here.)
Description
Dutch National Flag Algorithm- Implemented in C++.
Checklist
Related Issues or Pull Requests
(Write your answer here.)