7 kyu
Nth Smallest Element (Array Series #4)
862 of 12,649MrZizoScream
Loading description...
Fundamentals
Arrays
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Perl translation, please review.
Approved by someone
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/132.
Please join the discussion to help us identify duplicate kata and retire them.
This kata was decided to stay.
COBOL translation (author inactive).
Approved
No basic tests in Clojure.
added
R translation (author inactive)
Thanks :)
Ruby 3.0 should be enabled.
Description is formatted badly
Done and done
This comment has been hidden.
I made a Rust translation
Rate, comment and subscribe
Revised and BIG APPROVAL :+1:
too simpuh
Clojure Translation ready for review.
Revised and APPROVED :+1:
Why do this kata could be solved just by returning
true
inPHP
? Also I checked tests$this->assertEquals(2, true);
will pass too. Could somebody explain why this happens?UPD: This happens because
assertEqual
instead ofassertSame
used. InPHP
true == 1
and1 == true
, it casts digit to the boolean. And this is the root why the porblem arrise. https://stackoverflow.com/a/10254238/8574922Fixed, I opened an issue a while ago for problems like this. The issue is closed now and kazk said report in the kata. Maybe mark your post as having spoiler content next time so people who still didn't solve the kata don't use this to pass it?
Zizou: be aware of this, I've fixed 4 more of this kata series PHP translations. There is one more I couldn't edit.
@Chrono Can you list the ones you haven't done? (I can edit all kata; see https://github.com/codewars/codewars-runner-cli/issues/771#issuecomment-618170508)
That I'm aware of, this one: https://www.codewars.com/kata/5a7893ef0025e9eb50000013/discuss#5ed279d3904739002388eea9
Not tested in Prolog.
Tests added.
Prolog translation kumited.
Btw, how come there's 2 #4's in Array Series? o_O
Ooh my bad , I've hit the aging years of my life cycle , getting a bit senile :sweat_smile:
Revised and Senile Approaval :stuck_out_tongue_winking_eye:
Well I wrote a quick select because I remember hearing about it randomly at somepoint, useless for a 7kyu but I wanted to try it out at least.
@MP7373
What are the pitfalls of quick select (or did I do something wrong in my implementation other than not randomizing the pivot)? Is it stack overflow because I wrote it recursively or is it something else that happens with larger arrays? What are some better algorithms for solving this problem with very large arrays than quick select? Quick select is the only algorithm i've heard of that has average linear time complexity for getting the nth largest element.
NASM Translation! Please scrutinize and approve!
@pvtroswold
Looks Yummy :yum: , Revised and APPROVED :+1:
TypeScript translation
Revised and APPROVED :+1:
CoffeeScript translation :coffee:
Dart translation
\ ゜o゜)ノ
Yep , APPROVED
Julia translation
Revised and APPROVED :+1:
OOPS I accidentally did that dart thing in this kata too but it was for a different kata :( Please reject it: https://www.codewars.com/kumite/5d2d0bb6b7ae880025764e78?sel=5d2d0bb6b7ae880025764e78
Oops , You're Right , I've just had a look on the Solution Revealing it Was Adjacent Product , No Problem
This comment has been hidden.
@MrZizoScream, C and Java translations available.
@clcraig .. Revised and Approved .. Thanks Bro :wink: :+1:
Haskell : https://www.codewars.com/kumite/5b74d2e069826c271400000e?sel=5b74d2e069826c271400000e
@cliffstamp .. Thanks Cliff :relaxed: .. Approved :wink: :+1: ... Regards .. Zizou
The instructions in this Kata are a tad misleading. Where I thought the solution that was too obvious to be the answer was indeed the answer, it explicitely says "so Take duplications into account". In my head that means "ignore non-distinct indeces", whereas the solution, does not take non-distinct indeces into account.
This comment has been hidden.
@gtrstr .. Well , thanks for pointing out , I Think it was Pretty clear Don't remove Duplications since Over 160 Times Completed without mentioning this problem , But Any way , Description has been updated To include the note above ... Wish you all the best ON/OFF CW .. Regards .. Zizou
PHP translation added. Please review and approve.
@Edison2ST .. Approved :wink:
This comment has been hidden.
@AdmiralFigura ..
This comment has been hidden.
@realfg ..
This comment has been hidden.
This comment has been hidden.
What are the obvious reasons for
log n < k
?In artificial circumstances ( such as this kata ), I might agree with you, but in real life you might be interested in, say, the first to fail to medal in the Boston marathon -
k=4, n=30e3
or so.log2 30e3 ~ 15
.Worst case for
k
is a lot worse than forlog n
though. Hmmm ..What's the probability of
k
smaller than15
? ;-)You chose
4
here. But you need to not look at the tree and look at that30e3
forest ;-)All probabilities are 50%, always. :yum: Maybe you actually need to look at both, and choose best of
O(n log n)
andO(kn)
.Going with
O(n log n)
always is a reasonable rule of thumb, I guess.OK, back to the regularly scheduled "Thou shalt not mutate thy input" now ..
This comment has been hidden.
Thanks Matthias
For instructing ... The Whole Kata Was Revised Carefully .. Test cases Have benn Fixed ... Description has been reframed ... Algorithm header file and its whole content Is enabled now ... Hope you Enjoy it ...regards
The random tests generate the argument
nSmallest
independent of the size ofpassed
. That means they might asknthSmallest
to calculate the 198th smallest out of 2 integers.Revised Carefully And Fixed ...
Thanks
Duplicate:
https://www.codewars.com/kata/the-nth-smallest-integer
Okay .. no problem , i didnot scan katas before posting .. thanks for informing me ..
Not exactly a duplicate. The other is a little bit harder because it asks for the n-th smallest distinct element.
I saw the other kata moment ago .. And The new Descrpition (After Rephrasing it) Mention Ther difference between them in the Third point ...
thanks