|@Rahul Jadhav 1||466|
Given two numbers N and P, the task is to check if unit digit of N and NP are the same or not.
Input: N = "2", P = 1 Output: 1 Explanation: Unit digit of 21 is 2, which is equals to 2
Input: N = "4", P = 2 Output: 0 Explanation: Unit digit of 42 is 6, which is not equals to 4
You don't need to read input or print anything. Your task is to complete the function unitDigit() which takes a string N and an integer P as inputs and returns the boolean value.
Expected Time Complexity: O(|P|).
Expected Auxiliary Space: O(1).
1 <= |N| <= 50
1 <= P <= 1000
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes