Skip to content

Conversation

newbility77
Copy link

(Put an X inside the [ ] to denote check mark [X].)

  • If creating a new file :

    • added links to it in the README files ?
    • included tests with it ?
    • added description (overview of algorithm, time and space compleixty, and possible edge case) in docstrings ?
  • if done some changes :

    • wrote short description in the PR explaining what the changes do ?
      longest_non_repeat_v1 implementation has a bug. this PR is fixing it, please check the added test case.
    • Fixes #[issue number] if related to any issue
  • other

@coveralls
Copy link

coveralls commented Jul 7, 2018

Pull Request Test Coverage Report for Build 672

  • 16 of 16 (100.0%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 71.687%

Files with Coverage Reduction New Missed Lines %
algorithms/sort/top_sort.py 2 90.38%
Totals Coverage Status
Change from base Build 667: 0.1%
Covered Lines: 3803
Relevant Lines: 5305

💛 - Coveralls

add a test case for __contains__ for Interval
@newbility77 newbility77 changed the title fix longest_non_repeat_v1 and add test cases fix longest_non_repeat_v1 and add test cases, fix __contains in Interval and make some code concise Jul 7, 2018
for i in string:
if i in temp:
temp = []
temp = temp[temp.index(i) + 1:]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@newbility77 Nice catch! We could further optimize this code. Now it requires 2 traversals of temp in line23 and 24.
We can do in 1 traversal:

for i in string:
    for idx, c in enumerate(temp):
        if c == i:
            temp = temp[idx + 1:]
            break
    temp.append(i)
    ...

@danghai
Copy link
Collaborator

danghai commented Aug 15, 2018

We resolve it ! Reopen when you have another way.

@danghai danghai closed this Aug 15, 2018
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.

4 participants