/java-task

java coding task for Acamar

Primary LanguageJava

Acamar Java coding task

Please complete the coding exercises in this repo, upload code to a personal git repo, and share the link with us.

Please don't fork this repo. Download/Clone the repository, finish the exercise and upload it as a new repository in your github account. Share with us the link for that repository

Prerequisites

To build and run the sample code please make sure you have the following prerequisites

  • JDK 8+
  • Maven
  • Any IDE of your choice

Coding Exercise

This repository contains two tasks, each one is in a separate class.

Please implement the methods inside the classes according to the requirements specified in JavaDocs and make sure that all unit tests are green.

Task 1. Length of the last word.

The task is located in cz/acamar/tasks/Task1.java

Given a string s consisting of some words separated by some number of spaces,
return the length of the last word in the string.

A word is a maximal substring consisting of non-space characters only.

Example input: "Hello World"

Expected output: 5

Task 2. Squares of a sorted array.

The task is located in cz/acamar/tasks/Task2.java

Given an integer array sorted in non-decreasing order,
return an array of the squares of each number sorted in non-decreasing order.

Example input: [-4,-1,0,3,10]

Expected output: [0,1,9,16,100]

Explanation: After squaring, the array becomes [16,1,0,9,100].

After sorting, it becomes [0,1,9,16,100].

How to submit code?

Please upload completed code to a personal git repository and share the link to your repository with us.