arya2004 / leetcode-daily-october-hacktoberfest-2024

Leetcode Daily October Hacktoberfest 2024
MIT License
10 stars 49 forks source link

Add Day 19 solution in C++ #88

Closed prateek168 closed 1 month ago

prateek168 commented 1 month ago

🚀 What does this PR do? Adds a solution for the LeetCode Daily Challenge on (Day and Date) in C++. The solution implements a recursive approach to solve the problem "Find Kth Bit in Nth Binary String". 📝 Issue Reference: Fixes issue: # (Mention the issue number this PR solves)

🔍 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: C++ Time Complexity: O(n), where n is the depth of recursion. At each recursive level, the problem size reduces. Space Complexity: O(n), due to recursive function calls. 🌟 Additional Notes: This approach uses recursion to solve the problem. The key is to find the middle bit and recursively call the function on the appropriate part of the string. The mid element is always '1', and for other elements, depending on their position relative to mid, we either look in the previous sequence or invert the result.