https://github.com/geektimus/java-challenges
This repo will contain the solutions using Java 8 for some coding challenges
https://github.com/geektimus/java-challenges
challenge coding-challenges java-8
Last synced: 7 months ago
JSON representation
This repo will contain the solutions using Java 8 for some coding challenges
- Host: GitHub
- URL: https://github.com/geektimus/java-challenges
- Owner: geektimus
- Created: 2018-02-23T21:59:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-02T05:37:02.000Z (about 1 year ago)
- Last Synced: 2025-04-06T03:19:05.608Z (11 months ago)
- Topics: challenge, coding-challenges, java-8
- Language: Java
- Size: 101 KB
- Stars: 12
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java Coding Challenges
[](https://travis-ci.org/geektimus/java-challenges)
This repo will contain the solutions using Java 8 for challenges found on:
* Books
* Hacker Rank
* Codility
* CodeFights
## Challenges
### Codility
#### Can we sort an array with a simple swap?
We need to write a function that will return true if we can sort an array swapping only two elements.
#### Mystery number
We need to write a function to shuffle the digits on a number on a particular way. The first char with the last char,
the second char with the second to last char until we use all the digits.
#### Find the longest sentence.
We have phrases composed by sentences and each of this sentences contain words. We need to write a function that will
give us the number of words on the longest sentence. The sentences are separated by "?", "!", "." and the words simply
by spaces (" ").
#### Binary Gap
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
#### CyclicRotation
We need to perform an array shift to the right a given number of times.
#### Frog Jumps
A little frog wants to cross to the other side of the river, but it can only jump to the leaves that fall on the water
and only then the complete path from 0 to target has all required leaves.
Given the starting position 0, and a non empty array indexed by each second and the position of the leaf. Find the earliest
time when the frog can jump all the way from 0 to the target position.
#### Permutation Check
We need to perform a check on an array to see if it's a permutation of N elements where N original size of the array.
**Note:** A permutation is a sequence containing each element from 1 to N once, and only once.
#### Max Counter (Counter Operations)
We need to calculate the values of counters after applying all alternating operations: increase counter by 1; set
value of all counters to current maximum.
#### Minimum Number of Plays on a Casino (\*)
A guy walks out of a Casino with N chips. We know that he played W times an all in.
We need to find the minimum number of plays he could play on the casino to earn those N chips.
#### Factory of Shoes (\*)
We have a line of shoes composed of Left (L) and Right (R) shoes. We want to assign a group of workers to work on the
shoes, but we need to guarantee that we assign each worker a group of shoes that contains the same number of L and R shoes.
### Hacker Rank
#### Odd number generator
We need to write a function that return all the odd numbers on a range given the start and the end of the range as
integers. This collection will include the start and end integers if they are odd numbers too
### Books
#### Unique characters
We need to write a function that will tell us if all the characters on a given string are unique.
#### Check permutation
We need to write a function that given two strings let us find if one is a permutation of the other.
#### URL Friendly String
Given a String and its true length, transform the string to a URL friendly string by replacing the spaces by %20
**Note:** We can assume that the string contains a length that allow us to store the additional chars
without having to allocate a new string.
### Others (Challenges proposed by Friends or Solved on hackatons)
#### Recursively reverse a string
Given a string, reverse the characters and return
#### Find the first char that repeats itself on a given string
Given a string, find the first chat that repeats itself.
#### Sort server logs by two fields
We had to sort a list of logs given the log level, or the event timestamp.