@crazystonesss This is not likely to be true.
A sub-problem of your request s to do primality test in O(1) time (since the answer for a prime input n is just w =1). However, the complexity of primality test is not found to be O(1).
LeetCode Weekly Contest 16B
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.