![]() |
VOOZH | about |
Given two numbersA and B where (A > B), the task is to check if B is a prefix of A or not. Print "Yes" if it is a prefix Else print "No".
Examples:
Input: A = 12345, B = 12
Output: YesInput: A = 12345, B = 345
Output: No
Approach:
Below is the implementation of the above approach:
Yes
Time Complexity: O(n2), where n2 is the size of string s2
Auxiliary Space: O(1), as no extra space is required
Using in-built function: Using inbuilt function std::boost::algorithm::starts_with(), it can be checked whether any string contains prefix of another string or not.
Below is the implementation of the above approach:
Yes
Time Complexity: O(1)
Auxiliary Space: O(1)