- 1
Pls help me to solve this
Bala was given a task by his professor to find all the occurrences of a given word in the given string Help Bala to write a efficient program to complete his task. Note: Ignore the case Input Format String 1 in first line String 2 in second line Constraints NA Output Format Number of occurences Sample Input 0 Hai Hello hai her him hai hai Sample Output 0 3 Sample Input 1 An apple is red in colour red Sample Output 1 1 Sample Input 2 Spring is beautiful but so is winter is Sample Output 2 2
3 Answers
+ 2
Rajeshwari. S ,
please do a try by yourself first. if you get stuck, post the link to your code here.
thanks!
here is a hint how to get it done:
- there is a string method count(). we use it to get the number of occurrences of a substring in a string.
- you can apply it to the string that contains the sentence. ....count()
- give the single word string as an argument to count(....)
happy coding!
+ 1
And where's your code??