Showing posts with label string function calculation. Show all posts
Showing posts with label string function calculation. Show all posts

Sunday, April 10, 2016

HackerRank: string function calculation (II) - string algorithm - Boyer Moore Algorithm

April 10, 2016


  Problem statement:

https://www.hackerrank.com/challenges/string-function-calculation

  Time spent: 3:40pm - 4:40 pm

First hour work, score 8.9 out of 80 points. 
The solution: 
https://gist.github.com/jianminchen/09c77ba32b156f765b4debb2bccba0c8


Brute force solution:

pass one test case: aaaaaa, return 12,

use Boyer Moore Algorithm, still time out:

time spent: 8:00pm - 8:45pm 



copy Boyer Moore algorithm code from the webpage:

convert the class from Java to C#. 

Julia second try:  (time out issue - Boyer Moore Algorithm does not help!!!)




HackerRank: string function calculation - string algorithm - Brute Force Solution

April 10, 2016

  Problem statement:

https://www.hackerrank.com/challenges/string-function-calculation

  Time spent: 2:40pm - 3:35pm 20 minutes to think, 20 minutes to write down in C#

Understand the problem, so, here are her thoughts:

Brute force solution:

pass one test case: aaaaaa, return 12,

failed test case:
abcabcddd,
wrong answer - Easy fix, index error on the loop

score 8.89/ 80

one test case: wrong answer
All other test cases time out

https://gist.github.com/jianminchen/09c77ba32b156f765b4debb2bccba0c8

Need to work on KMP, or Boyer-Moore algorithm, see how to make HackerRank happy, score more points.

http://www.cs.tufts.edu/comp/150GEN/classpages/BoyerMoore.html

blog:
http://juliachencoding.blogspot.ca/search/label/string%20functions%20review