We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
From our pure mathematical point of view, the complexity of Java "bitCount" method is O(K) because it takes exactly the same number of operations (namely, "K") to compute the "bitCount" for any value of N. Since K is a constant and independent of N, the complexity may be rewritten as O(K) = O(1). Therefore, the complexity of "bitCount" is indeed O(1). Please feel free to read the following URL for further evidence: http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/2d585507a41b/src/share/classes/java/lang/Long.java
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
From our pure mathematical point of view, the complexity of Java "bitCount" method is O(K) because it takes exactly the same number of operations (namely, "K") to compute the "bitCount" for any value of N. Since K is a constant and independent of N, the complexity may be rewritten as O(K) = O(1). Therefore, the complexity of "bitCount" is indeed O(1). Please feel free to read the following URL for further evidence: http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/2d585507a41b/src/share/classes/java/lang/Long.java