Import random in python?


  • 0
    W

    Trying to import random in Python gives a compile error. The module is not loaded by default either.
    What's the easiest way to generate pseudorandom integers?


  • 0
    S

    Can you explain why you need a random number generator in the first place. I presume that you may want to try a randomized algorithm, but that is probably not the kind of answer your interviewer might be expecting; All questions on OJ are supposed to be solved in a deterministic way, as do most interview questions in real life.


  • 0
    W

    Yes I was going to try a randomized algorithm, but I found a better solution now.

    However, I was hoping to find out if it is possible in general to use the random module in OJ. Is it just allowed for certain problems? Or not at all?


  • 0
    Y

    It seems leetcode doesn't allow importing modules.


  • 0
    N

    I want use QuickSelect algorithm! now how can i do this in leetcode?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.