Skip to content
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

Adding Javascript Solution for Day 15 #80

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

Nisha-Rao21
Copy link

@Nisha-Rao21 Nisha-Rao21 commented Oct 15, 2024

🚀 What does this PR do?

  • Adds solution for LeetCode Daily Challenge on (Day 15) in (Javascript).
  • We traverse the string from left to right to check if we encounter a 1 or a 0.
  • Maintaing 2 counters: one to count the numberOfOnes encountered and one to store the final result of min swaps.
  • In case if we reach a 1, increment numberOfOnes counter.
  • In case of a 0, minSwaps += numberOfOnes

📝 Issue Reference:

Fixes issue: #15

🔍 Checklist:

Please ensure the following before submitting your PR:

  • I have placed my solution in the correct folder (solutions/dayXX/).
  • My code follows clean coding practices and is efficient.
  • I have added comments in my code to explain the approach.
  • I have updated the README.md for the specific day with a brief explanation of my solution.
  • I have tested the solution on LeetCode and it works correctly.

🔧 Solution Details:

  • Language Used: Javascript
  • Time Complexity: O(n)
  • Space Complexity: O(1)

🌟 Additional Notes (if any):

image

@arya2004 arya2004 merged commit db1cd6a into arya2004:main Oct 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants