(Senior Developer)

Reputation: 1 [rate]

Joined: Jul, 2022

Last online:

Profile Picture


Hello, my name is Mobi Wan, and I'm a Prolific Java programmer with 4+ years of experience.

Activity Feed

Created a new thread: KMP algorithm's time complexity

I'm attempting to implement strstr using the KMP method. This is the algorithm as described in Wikipedia & scaler topics. The temporal complexity of the KMP algorithm is O(n), where n is the length of the bigger string.

vector<int> KMP(string S, string K)
    vector<int> T(K.size() + 1, -1);
    vector<int> matches;

    if(K.size() == 0)
        return matches;
    for(int i = 1; i <= K.size(); i++)
        int pos = T[i - 1];
        while(pos != -1 && K[pos] != K[i - 1]) pos = T[pos];
        T[i] = pos + 1;

    int sp = 0;
    int kp = 0;
    while(sp < S.size())
        while(kp != -1 && (kp == K.size() || K[kp] != S[sp])) kp = T[kp];
        if(kp == K.size()) matches.push_back(sp - K.size());

    return matches;

I'm not sure how the complexity of this algorithm is O. (n). Can somebody explain how this code's complexity is O(n)?

Created a new thread: Java equals() selection

In Java, if I try to do.equals() on a null string, a null pointer error is issued. I'm wondering whether I can perform the following if I'm attempting to compare if a string is equal to a constant string:


MY CONSTANT STRING.equals(aStringVariable)

I'm sure it'll work, but is this simply extremely bad code?

This is a common Java idiom known colloquially as a Yoda condition. Personally, I prefer to handle the null situation directly, but the Yoda method is widely used, and any competent Java programmer should quickly grasp what is going on. How should I proceed?

Created a new thread: How can I use a Bash script to see if a software exists?

How would I check the existence of a program in such a way that it either returns an error and exits or continues with the script?

I'm reading this article from scaler academy and It appears to be simple, yet it has confounded me. Can someone help me out?

Created a new thread: When deployed to Heroku, python setup.py egg info did not run successfully.

Hi everybody,
I joined this group to learn more about web development. I am familiar with Java, C, and HTML, and am actively learning CSS and Python. And I'm facing some issue! Can somebody help me?

After deploying and hosting my website, I upgraded my pip version. Then I installed the pypaystack package. When I try to push to Heroku, I get the error shown below. In the development stage, the project is running smoothly.

  Collecting pypaystack==1.24
remote:          Downloading pypaystack-1.24.tar.gz (5.4 kB)
remote:          Preparing metadata (setup.py): started
remote:          Preparing metadata (setup.py): finished with status 'error'
remote:          error: subprocess-exited-with-error
remote:          × python setup.py egg_info did not run successfully.
remote:          │ exit code: 1
remote:          ╰─> [12 lines of output]
remote:              Traceback (most recent call last):
remote:                File "<string>", line 2, in <module>
remote:                File "<pip-setuptools-caller>", line 34, in <module>
remote:                File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/setup.py", line 2, in <module>
remote:                  from pypaystack import version
remote:                File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/__init__.py", line 3, in <module>
remote:                  from .customers import Customer
remote:                File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/customers.py", line 1, in <module>
remote:                  from .baseapi import BaseAPI
remote:                File "/tmp/pip-install-h6ay7jb3/pypaystack_2a3b97aa3d934da4b6c7a7d81a4a6ad2/pypaystack/baseapi.py", line 2, in <module>
remote:                  import requests
remote:              ModuleNotFoundError: No module named 'requests'
remote:              [end of output]
remote:          note: This error originates from a subprocess, and is likely not a problem with pip.
remote:        error: metadata-generation-failed
remote:        × Encountered error while generating package metadata.
remote:        ╰─> See above for output.
remote:        note: This is an issue with the package mentioned above, not pip.
remote:        hint: See above for details.
remote:  !     Push rejected, failed to compile Python app.

What can be the issue? I even created a new virtual environment but the error remains.
I'm hoping that this community will assist me on my path.