Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added recursion solutions: Regular Expression Matching and N-Queens#522

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
avimishraa wants to merge1 commit intocodedecks-in:master
base:master
Choose a base branch
Loading
fromavimishraa:recursion-hard-problems

Conversation

@avimishraa
Copy link

This Pull Request adds two hard-level recursion problems from LeetCode, implemented in C++ with clear explanations, optimized recursion logic, and tested outputs.

  1. Regular Expression Matching (LeetCodeUpdated Readme + TwoSums + Longest Palindromic Substring #10)

Problem Summary:
Implement regular expression matching with support for '.' (matches any single character) and '*' (matches zero or more of the preceding element).

Approach:
Used pure recursion to explore all matching possibilities.

Base condition checks if the pattern is empty.

If the next pattern character is *, recursively try two options:

Skip the * and its preceding character.

Use it if the first characters match.

Otherwise, recursively match the next substring and subpattern.

Complexity:

Time: Exponential (in worst case), can be optimized with DP.

Space: O(N) recursion stack.

  1. N-Queens (LeetCodeHappy Number #51)

Problem Summary:
Place n queens on an n×n chessboard such that no two queens attack each other.

Approach:
Implemented a recursive backtracking algorithm that places queens row by row:

At each row, try placing a queen in a valid column (not under attack).

Track columns and diagonals using three boolean arrays.

If all rows are filled successfully, store the board configuration.

Backtrack when conflicts occur.

Complexity:

Time: O(N!) (due to backtracking and branching at each row).

Space: O(N²) for the board and recursion depth.

@welcome
Copy link

welcomebot commentedOct 22, 2025

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@avimishraa

[8]ページ先頭

©2009-2025 Movatter.jp