Giter Site home page Giter Site logo

java-challenges's Introduction

Java Coding Challenges

Build Status

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.

java-challenges's People

Contributors

geektimus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.