Skip to main content

All Questions

2 votes
1 answer
80 views

Sort array of numbers using tree sort - Leetcode 912

Problem statement: Sort integer array nums in O(N log N) time, without relying on any library sort routine. I am trying to use a tree sort method (using the ...
qxzsilver's user avatar
  • 123
5 votes
3 answers
875 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. ...
ChickenCoding123's user avatar
1 vote
0 answers
88 views

Python Bubble sort

...
Leonard's user avatar
  • 131
6 votes
1 answer
751 views

Timeout Error in Fraudulent Activity Notification HackerRank

I am solving this problem: Fraudulent Activity Notifications on HackerRank. I am done with my code and is working, but it is inefficient as well for very large inputs. I don't know but after all ...
Alok's user avatar
  • 201
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 ...
Roland's user avatar
  • 141
2 votes
1 answer
98 views

Finding maximum homework grade ECOO 2018

I'm trying to solve ECOO 2018 round 2(regionals) question 2 to prepare for the upcoming contest. Basically, in the question George has to achieve the maximum possible grade by completing the right ...
Michael exe's user avatar
0 votes
2 answers
183 views

Select nth smallest distinct integer from inputs

Kata in question Given a list of integers, return the nth smallest integer in the list. Only distinct elements should be considered when calculating the answer. n will always be positive (n > 0) ...
Tobi Alafin's user avatar
  • 1,796
5 votes
2 answers
3k views

Hackerrank "Almost Equal" solution

I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
Mark Mc Adam's user avatar
1 vote
1 answer
342 views

Verify that each named sequence is strictly increasing

The master launch sequence consists of several independent sequences for different systems. Your goal is to verify that all the individual system sequences are in strictly increasing order. In other ...
JRowan's user avatar
  • 121
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 ...
anand powai's user avatar
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 ...
loremIpsum1771's user avatar
6 votes
2 answers
3k views

Minimum swaps algorithm terminated due to timeout

I have been trying to solve this question. Given an unordered array consisting of consecutive integers [1, 2, 3, …, n], find the minimum number of two-element swaps to sort the array. I was able ...
Ugur Yilmaz's user avatar
6 votes
3 answers
1k views

C++ code to read, sort, and write data

I had written code in C++ to create transformation filters to get input, sort (custom_sorting and existing sorting routine) and write the output to stdin and file. When I presented it to my teacher, ...
Akshaya's user avatar
  • 63
3 votes
1 answer
1k views

Sorting a 2-dimensional array with counting sort

The task I'm solving is: Sort a list by its keys Print out the corresponding values on one line separated by whitespace Replace the values of the first half of the input to "-" Use Counting Sort The ...
hooni's user avatar
  • 33
4 votes
2 answers
639 views

Counting adjacent swaps to sort an array with 3 different values

This is the Kindergarten Excursion problem from kattis.com: The kindergarten teachers had finally managed to get all the kids in a line for the walk to the bus station and the weekly excursion. ...
gal zakrajsek's user avatar

15 30 50 per page