Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
sande11128y@apex Though the actual solution would've been O(n^2)(or O(n*log(n)) , this code is O(n) since O(c*n) =O(n). Just a very very bad O(n).
-
@apex technically, he's right... Since the outer loop doesn't grow with the number of strings, it's essentially a constant. It's not trivial, but it's true.
-
I feel like this is still technically Theta(n^2), because it only works if n<=c where c is the constant, right? So c*n would have to be at least n*n, which makes c no longer constant because it would have to get infinitely large as the length of the string gets infinitely large
Related Rants
-
sulemartin8714was at a hackathon, had to write an app that sent current location to emergency contact. hard coded the locati...
-
bilange14First time poster here. Please be nice :) My biggest workaround is one that's being currently deployed to 40 ...
-
daarkfall5Like many others my favourote shameless hack is a cronjob to restart our app server at 2am, thus preventing ou...
In a programming exam, we had to write a program in 60 minutes, part of which was sorting some strings by length (strings the same length had to be in the same line)... I had like 3 minutes left, so i wrote this beauty:
boolean b = false;
for(int i = 0; i <= 999999; i++){
for(int j = 0; j <= strings.length; j++){
if(i == strings[j].length()){
System.out.print(s + " ");
b = true;
}
}
if(b){
System.out.println();
b = false;
}
}
undefined
wk19
exam
i didn't deserve to pass