diff --git a/pom.xml b/pom.xml index 2a6372d..18e10ff 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,12 @@ InterviewProblem1 1.0-SNAPSHOT + + UTF-8 + 1.8 + 1.8 + + diff --git a/src/main/java/io/zipcoder/Problem1.java b/src/main/java/io/zipcoder/Problem1.java index 6cd6024..e2bbc30 100644 --- a/src/main/java/io/zipcoder/Problem1.java +++ b/src/main/java/io/zipcoder/Problem1.java @@ -1,4 +1,61 @@ package io.zipcoder; +//Example: +//One method using iteration, another using recursion +//Given the following map { ‘f’ : ‘7’, ‘s’:’$’, ‘1’:’!’, ‘a’.:’@’}, your method should +// replace any character represented by a key in the map, with its corresponding value. +//Input = “The Farmer went to the store to get 1 dollar’s worth of fertilizer” +// Output = “The 7@rmer went to the $tore to get ! doll@r’$ worth of 7ertilizer” public class Problem1 { + + public static String iterativeSolution(String input){ + + input=input.replaceAll("[f|F]\\B", "7"); + char[] charArray = input.toCharArray(); + + for (int i=0; i