Skip to main content

All Questions

1vote
0answers
23views

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\$ ...
greybeard's user avatar
0votes
2answers
608views

Pancake sort inteview using java

Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
Anirudh Thatipelli's user avatar
5votes
1answer
6kviews

Sort a given string in ascending order

This code sort the string below in ascending order. I'd prefer it split-up in two or three smaller, simpler methods. I'm also wondering whether my algorithm has a decent time complexity. Given string ...
Adam's user avatar
  • 405
1vote
1answer
2kviews

Closest Numbers

Online coding challenge Hacker Rank. Given a list of unsorted integers, find the pair of elements that have the smallest absolute difference between them? If there are multiple pairs, find them all. <...
CodeYogi's user avatar
3votes
3answers
389views

Sorting and eliminating duplicates

From Hacker Earth: Problem Statement: Chotu's father is the owner of a Vada Pav shop. One Sunday, his father takes him to the shop. Father tells him that at the end of the day, Chotu has to give him ...
Kaushal28's user avatar
3votes
1answer
1kviews

Printing longest lines

Challenge Write a program which reads a file and outputs a specified number of lines, sorted on length in descending order. Specifications The first argument is a path to a file. The file contains ...
Legato's user avatar
  • 9,839
3votes
3answers
2kviews

Hackerrank Insertion Sort Part 2

I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort. The challenge was : In Insertion Sort ...
Dhrubojyoti Bhattacharjee's user avatar
7votes
2answers
2kviews

Project Euler 22: Names scores

Description of challenge: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then ...
TheCoffeeCup's user avatar
5votes
3answers
1kviews

Counting number of inversions

This is a HackerEarth Challenge Problem. Question: Puchi hates to carry luggage, but unfortunately he got a job to carry the luggage of his N friends in office. Each day, one of his N friends, ...
aakansha's user avatar
1vote
4answers
383views

Finding the second largest element of large input sets

I have a problem where I need to find the second maximum element of the user inputs. It's an online practice problem and I can't figure out why the server responds back with a Non-Zero Exit Code error ...
arindrajit's user avatar
8votes
4answers
27kviews

Arranging words in sentences alphabetically

For an online contest whose problem is here, I wrote some code. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the ...
RE60K's user avatar
  • 1,466

close