Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

time-complexity

How to improve performance of this code?

August 22, 2022 by Magenaut

Thanks to some help from people here, I was able to get my code for Tasmanian camels puzzle working. However, it is horribly slow (I think. I’m not sure because this is my first program in Python). The example run in the bottom of the code takes a long time to be solved in my machine:

Categories Python, Q&A Tags optimization, performance, python, time-complexity Leave a comment

Find common substring between two strings

August 20, 2022 by Magenaut

I’d like to compare 2 strings and keep the matched, splitting off where the comparison fails.

Categories Python, Q&A Tags algorithm, dynamic-programming, python, string, time-complexity Leave a comment

Is the time-complexity of iterative string append actually O(n^2), or O(n)?

August 19, 2022 by Magenaut

I am working on a problem out of CTCI.

Categories Python, Q&A Tags algorithm, python, string, string-concatenation, time-complexity Leave a comment

Complexity of *in* operator in Python

August 18, 2022 by Magenaut

What is the complexity of the in operator in Python? Is it theta(n)?

Categories Python, Q&A Tags python, time-complexity Leave a comment

Time complexity of string slice

August 17, 2022 by Magenaut

What’s the time complexity of slicing a Python string? Given that Python strings are immutable, I can imagine slicing them being either O(1) or O(n) depending upon how slicing is implemented.

Categories Python, Q&A Tags python, time-complexity Leave a comment

Time complexity of string concatenation in Python

August 14, 2022 by Magenaut

I’m analysing the complexity of my code. From what I found online, since strings are immutable in python, a concatenation of a string and a character should be O(len(string) + 1). Now, here is my piece of code (simplified): word = "" for i in range(m): word = char_value + word return word The total … Read more

Categories Python, Q&A Tags python, string, time-complexity Leave a comment

Why is the time complexity of python’s list.append() method O(1)?

August 14, 2022 by Magenaut

As seen in the documentation for TimeComplexity, Python’s list type is implemented is using an array.

Categories Python, Q&A Tags amortized-analysis, python, python-2.7, time-complexity Leave a comment

Python collections.Counter: most_common complexity

August 12, 2022 by Magenaut

What is the complexity of the function most_common provided by the collections.Counter object in Python?

Categories Python, Q&A Tags counter, python, python-collections, time-complexity Leave a comment

Sliding window maximum in O(n) time

August 12, 2022 by Magenaut

Input:

Categories Python, Q&A Tags algorithm, dynamic-programming, list, python, time-complexity Leave a comment
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress