Write a function which returns a new string which is made by concatenating a given string n number of times.
Input : str = "geeks" n = 3 Output : str = "geeksgeeksgeeks" We concatenate "geeks" 3 times Input : str = "for" n = 2 Output : str = "forfor" We concatenate "for" 2 times
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to concatenate two given Matrices of same size
- C Program to concatenate two strings without using strcat
- Concatenate suffixes of a String
- Methods to concatenate string in C/C++ with Examples
- Concatenate strings in any order to get Maximum Number of "AB"
- How to concatenate two Integer values into one?
- Concatenate the strings in an order which maximises the occurrence of subsequence "ab"
- Number of times the given string occurs in the array in the range [l, r]
- Repeat substrings of the given String required number of times
- Longest sub string of 0's in a binary string which is repeated K times
- Count of times second string can be formed from the characters of first string
- Check if any permutation of string is a K times repeated string
- String obtained by reversing and complementing a Binary string K times
- Smallest String consisting of a String S exactly K times as a Substring
- Find if a given string can be represented from a substring by iterating the substring “n” times
- Print the string after the specified character has occurred given no. of times
- Number of subsequences as "ab" in a string repeated K times
- Number of sub-strings that contain the given character exactly k times
- Queries to print the character that occurs the maximum number of times in a given range
- Check if X and Y can be made zero by using given operation any number of times