I have already done it and provided link to my solution. Learn to read, retard.
James Williams
Sorry bro I'm not going to do your comp sci 2 homework
Gabriel Adams
>"Let's see how many brainlets are on Sup Forums" >uses python
Brandon Harris
Hello summer
Adrian Scott
your solution is in linear time, but is not better than O(n) time. Its something like O(10n) time, but lets just pretend you meant linear time so that your solution fits the parameters.
Other than me being a dick just now, I doubt this can be done better than linear time and the most straightforward solution is something along the lines of the swap solution you provided.
If you remove the constant space complexity requirement, this could be made into real O(n) time by just reading into a new matrix.
Chase Hill
It can be done in leinear time.
Camden Martin
>O(10n) This notation is literally never used. It doesn't matter if it is n, 2n, or 44n + 365, it is alway O(n)
Logan Taylor
but can it be done better?
the solution already was a linear time solution it just wasnt O(n)
Dominic Taylor
then call it linear time
Liam Taylor
No. It can not be improved. You need tomove every elements (except centre if there is one).
O(n) and O(100n) are exactly the same thing. I hope you understand why.
Hunter Taylor
im just pedant
Jack Hernandez
>If I post a bad solution Sup Forums will correct me and do my homework for me! Really?
Camden Lopez
>im just pedant No. You justfail to understand why big O notation was introduced,
Jaxon Turner
And why exactly is my solution bad, faggot? And who the fuck have uni in middle of summer
Jace White
>1 = 100 >your brain on CS
Jaxon Adams
I'm laughing so hard right now, this is the perfect example of Sup Forums in 2017. Not surprised that most threads are about consumerism, when you are failing CS 101.
Oliver Ramirez
Do your own homework, cunt. Or ask /wsr/. I'm not gonna sit here and say why it's bad so you can fix it. Go learn and put forth effort.
Gabriel Williams
this is really poor attempt at trolling, sorry.
Lucas Howard
>nobody does your homework for you >f-f-f fucking Sup Forums newfags! I b-b-bet youre the ones failing cs 101!
Alexander Myers
Not as bad as your attempt to get people to do your homework for you.
Ryder Ross
I was pointing out they fucking doesn't understand what a Big O notation is. Back to "watz da best gpu for gayming" threads
Caleb Sullivan
I dunno, he has done the task, why would he ask anyone to do the done job?
Caleb Torres
>Daily programming challenge What was yesterday's challenge?
Jeremiah Green
O(n) literally means linear
Blake Williams
are you kidding me? even the most obvious solution is O(n).
>someone doesn't know what O(n) means a function f is O(g(n)) if there exists a c > 0 such that f(n) < cg(n) for all n. as an application, any function that is O(100n) is O(n).
Josiah Wright
depending on how your matrix is stored, the solution can be done in O(1). but optimizing your data structure for such problems will leave it relatively useless for most other things.
Samuel Cook
Any pb can be solved in O(1) with a gopd coding.
Cameron Nguyen
okay, perform element-wise addition of two integer arrays (each of length n) in O(1).
Sebastian Butler
I'd just use a reverse iterating vector in C++ easy peasy