Skip to content

Conversation

@Feminto
Copy link

@Feminto Feminto commented May 29, 2025

No description provided.

@BharathVuppala96
Copy link

Good Work

@super30admin
Copy link
Owner

  1. Correctness:

    • friend_requests_II: The solution correctly identifies the person with the most friend requests by combining requester and accepter counts. It handles the problem well.
    • league_stats: The solution accurately calculates team statistics by considering both home and away matches, including points, goals, and goal difference. The ordering is correct.
    • num_of_seniors_juniors: The solution correctly calculates the number of senior and junior candidates that can be hired within the budget, though it could be simplified.
    • sales_person: The solution correctly identifies salespersons who didn't have orders with 'RED' company.
  2. Time Complexity:

    • friend_requests_II: O(N) for the initial aggregation and O(N) for the final selection, where N is the number of records.
    • league_stats: O(M) for processing matches (M is number of matches) and O(T) for joining with teams (T is number of teams).
    • num_of_seniors_juniors: O(N log N) due to the sorting in the window function, where N is the number of candidates.
    • sales_person: O(N) for the join and filtering, where N is the number of orders.
  3. Space Complexity:

    • All solutions use additional space for CTEs, but this is reasonable for SQL queries. The space complexity is generally O(N) where N is the size of the input data.
  4. Code Quality:

    • The code is generally well-structured and readable.
    • Consistent use of CTEs improves readability.
    • Some queries could be simplified (e.g., num_of_seniors_juniors could avoid redundant calculations).
    • Proper indentation and formatting are maintained.
  5. Efficiency:

    • friend_requests_II: Efficient, but the subquery could be replaced with a simpler approach using ORDER BY and LIMIT.
    • league_stats: Efficient and well-optimized.
    • num_of_seniors_juniors: The query could be simplified by combining the senior and junior calculations in a single pass.
    • sales_person: Efficient, but using NOT EXISTS might be more readable than NOT IN.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants