updated readme

This commit is contained in:
rshaghoulian
2017-04-30 18:30:26 -07:00
parent 9b6ef0f13b
commit 7145449310
57 changed files with 287 additions and 268 deletions
@@ -0,0 +1,36 @@
// Author: Rodney Shaghoulian
// Github: github.com/rshaghoulian
// HackerRank: hackerrank.com/rshaghoulian
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
/* Save input */
Scanner scan = new Scanner(System.in);
String str = scan.next();
long n = scan.nextLong();
scan.close();
/* Found out # of times 'a' appears in our String */
int wordAs = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == 'a') {
wordAs++;
}
}
long completeWords = n / str.length();
long remainingLetters = n % str.length();
long totalAs = completeWords * wordAs;
/* Count up the remaining 'a' characters */
for (int i = 0; i < remainingLetters; i++) {
if (str.charAt(i) == 'a') {
totalAs++;
}
}
System.out.println(totalAs);
}
}