Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
The invariable units digit
Easy Accuracy: 9.99% Submissions: 20 Points: 2

Given two numbers N and P, the task is to check if unit digit of N and NP are the same or not.

Example 1:

Input: N = "2", P = 1
Output: 1
Explanation: Unit digit of 21 is 2, 
which is equals to 2

Example 2:

Input: N = "4", P = 2
Output: 0
Explanation: Unit digit of 42 is 6,
which is not equals to 4 

Your Task:
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

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

The invariable units digit

Output Window