Practical exercises continuation from Cracking The Interview Code. Exercise solutions for problems of different nature on HackerRank.

This repo is focus the weekly challenges presented in HackerRank, for each code you can find the problem link at the header and the solution followed below.

Also, there is a couple of code related to the Interview Cake weekly Java-based solutions. Interview cake is a interview tips.

Dependencies

This project was compiled using Eclipse and the build automation tool Maven. Maven projects are configured using a Project Object Model stored in a pom.xml. For example:

<project>
  <!-- model version is always 4.0.0 for Maven 2.x POMs -->
  <modelVersion>4.0.0</modelVersion>
  <!-- project coordinates, i.e. a group of values
    which uniquely identify this project -->
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0</version>
  <!-- library dependencies -->
  <dependencies>
    <dependency>
      <!-- coordinates of the required library -->
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <!-- this dependency is only used for running and compiling tests -->
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

The Maven directory structure will be as follows:

Directory namePurpose
project homeContains the pom.xml and all subdirectories.
src/main/javaContains the deliverable Java sourcecode for the project.
src/main/resourcesDeliverable resources, e.g. property files.
src/test/javaContains the testing Java sourcecode for the project.
src/test/resourcesContains resources necessary for testing.

HackerRank allowed time complexities

max n (<=)max O(n)
10..11n! or n^6
15..182^n * n^2
18..222^n * n
100n^4
400n^3
2Kn^2 * log n
10Kn^3
1Mn * log n
100Mn or log n
< 100MO(1)

See the code-interview-exercises repository.

Tags: algorithms arrays dynamic-programming exercises greedy hashtable java search sorting strings