Hi,
I was wondering how the runtime is calculated upon code submission?
I submited a solution for this problem(code below) and with VPN on, while connected to a neighbour country, got some 30ms. I said yeah whatever but after checking the charts I noticed some code examples that should not perform better than my code and this started bothering me why this is the case?
After that switched the VPN off and got 15ms which is quite an improvment.
Thanks!
public String[] divideString(String s, int k, char fill) {
int resLength = 0;
if (s.length() % k == 0){
resLength = s.length() / k;
}else{
while(s.length() % k != 0){
s += fill;
}
resLength = s.length() / k;
}
String[] res = new String[resLength];
int resCounter = 0;
for (int i = 0; i < s.length(); i+=k){
String test = s.substring(i,k+i);
res[resCounter] = test;
resCounter++;
}
return res;
}