Skip to content

solution to both problems#51

Open
avishwak wants to merge 1 commit intosuper30admin:mainfrom
avishwak:main
Open

solution to both problems#51
avishwak wants to merge 1 commit intosuper30admin:mainfrom
avishwak:main

Conversation

@avishwak
Copy link

@avishwak avishwak commented Jun 7, 2025

No description provided.

@super30admin
Copy link
Owner

  1. Correctness:

    • For Problem 1 (Article Views I), both solutions correctly identify authors who viewed their own articles and return the unique author IDs sorted in ascending order. The first solution uses pandas operations directly, while the second converts to a NumPy array and back. Both approaches are correct.
    • For Problem 2 (Invalid Tweets), the solution correctly filters tweets with content length greater than 15 characters and returns their tweet IDs.
  2. Time Complexity:

    • Problem 1:
      • First solution: O(n log n) due to the sort operation, where n is the number of rows.
      • Second solution: O(n) for filtering and unique operation, plus O(m log m) for sorting unique values (m ≤ n).
    • Problem 2: O(n) for filtering based on string length, where n is the number of rows.
  3. Space Complexity:

    • Problem 1:
      • First solution: O(n) in the worst case (all authors viewed their own articles).
      • Second solution: O(m) where m is the number of unique authors who viewed their own articles.
    • Problem 2: O(k) where k is the number of invalid tweets.
  4. Code Quality:

    • The code is generally well-structured and readable.
    • For Problem 1, having two implementations in the same file is confusing. It would be better to choose one and remove the other.
    • The use of method chaining in the first solution of Problem 1 is good practice but could be split into multiple lines for better readability.
    • Variable names are clear and descriptive.
  5. Efficiency:

    • For Problem 1, the second solution might be more efficient for large datasets as it avoids creating intermediate DataFrames and uses NumPy's unique operation.
    • For Problem 2, the solution is already efficient, but using str.len() > 15 is slightly more efficient than str.len().gt(15).

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