All Questions
Tagged with sorting programming-challenge
46 questions
8
votes
5
answers
1k
views
LeetCode 977: Squares of a sorted array, maintaining non-decreasing order
I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement.
Squares of a Sorted Array
Given an integer array ...
1
vote
0
answers
33
views
Determine top t values with few calls to order(), a given procedure to order k values, Java take 2
My 2nd take of the problem in Determine top t values with few calls to order(), a given procedure to order k values:
Given an array and a procedure to order \$k\$ ...
1
vote
1
answer
2k
views
HackerRank CountingSort 1 in C#
Comparison Sorting
Quicksort usually has a running time of n x log(n), but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison ...
-2
votes
3
answers
841
views
CodeForce 230 Dragon Fighting, Sorting without using array
Problem: https://codeforces.com/problemset/problem/230/A
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all \$n\$ dragons that live on this ...
5
votes
3
answers
895
views
Counting swaps in a sequence sorting algorithm
I have been working on this question, https://open.kattis.com/problems/sequences.
You are given a sequence, in the form of a string with characters ‘0’, ‘1’, and ‘?’ only. Suppose there are n ‘?’s. ...
1
vote
1
answer
283
views
MSD Radix sort in Place in c++, Object/Pointer Oriented
Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n)
I did a radix sort in place to not get a auxliar array. In the process i discorver a few things.
Is imposible to do LSD radix sort in place ...
2
votes
1
answer
174
views
LeetCode: Queue Reconstruction by Height C#
https://leetcode.com/problems/queue-reconstruction-by-height/
Suppose you have a random list of people standing in a queue. Each
person is described by a pair of integers \$(h, k)\$, where \$h\$ ...
6
votes
3
answers
3k
views
LeetCode: Top K Frequent Elements C#
https://leetcode.com/explore/interview/card/top-interview-questions-medium/110/sorting-and-searching/799
Given a non-empty array of integers, return the k most frequent
elements.
Example 1:
...
3
votes
3
answers
1k
views
JavaScript Sort Stack Coding Challenge
A coding challenge to write a function sortStack that receives a stack of integers into ascending order (with largest integers on top) and returns another stack ...
3
votes
3
answers
4k
views
New Year Chaos JavaScript, needs to be sped up
Similar to this question but this is for Python
Original problem with description on hacker rank
I am currently trying to iterate through a large number of arrays and count how many times numbers ...
6
votes
3
answers
43k
views
Minimum number of swaps required to sort the array in ascending order
Here is my problem statement. An excerpt:
You are given an unordered array consisting of consecutive integers ∈ [1, 2, 3, ..., n] without any duplicates. You are ...
5
votes
2
answers
238
views
Deficient Numbers
I have found the following interesting challenge on the web:
Deficient Numbers
A number is considered deficient if the sum of its factors is less than twice that number.
For example: 10 is a
...
5
votes
3
answers
5k
views
Sort characters in a Python string by frequency
I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of ...
5
votes
1
answer
98
views
Sorting software version list using Python 2.7 (no modules)
I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution:
...
4
votes
3
answers
219
views
Sort a linked-list with only three distinct values
I am trying to solve this problem. The problem is to sort a linked list containing only 0s, 1s and 2s by changing their links.
Sort a linked list of 0s, 1s and 2s by changing links Given a linked
...