algorithms

package
v0.0.0-...-cb72c30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 1 Imported by: 0

README

Repeated String

https://www.hackerrank.com/challenges/repeated-string/problem

There is a string,s , of lowercase English letters that is repeated infinitely many times. Given an integer, n, find and print the number of letter a's in the first n letters of the infinite string.

Example
s = 'abcac`
n = 10

The substring we consider is abcacabcac, the first characters of the infinite string. There are 4 occurrences of a in the substring.

Function Description

Complete the repeatedString function in the editor below.

repeatedString has the following parameter(s):

  • s: a string to repeat
  • n: the number of characters to consider

Returns

  • int: the frequency of a in the substring
Sample Input

Sample Input 0

aba
10

Sample Output 0

7

Explanation 0
The first letters of the infinite string are abaabaabaa. Because there are a's, we return .

Sample Input 1

a
1000000000000

Sample Output 1

1000000000000

Explanation 1
Because all of the first letters of the infinite string are a, we return .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepeatedString

func RepeatedString(s string, n int64) int64

func RepeatedString1

func RepeatedString1(s string, n int64) int64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL