New update is available. Click here to update.

Last Updated: 5 Jan, 2021

Difficulty: Easy

```
Number N may be very large.
```

```
The first line contains an integer 'T' denoting the number of test cases to be run. The 'T' test cases follow.
The first line of each test case contains a single number 'N' in the form of a string.
```

```
For each test case, print an integer denoting the remainder when 'N' is divided by 11.
```

```
1 <= T <= 5
1 <= length of N <= 10 ^ 6
Time Limit: 1 sec
```

- Since the number is very large we can not simply calculate
**N % 11.** - Now, any number say 256 % 11 can be calculated as (25*10 + 6)%11. Which in turn can be calculated as (( 25*10)%11+ 6)%11 or ( (25%11)*10 + 6)%11. Similarly 25%11 can be calculated as (2*10+5)%11. Therefore , 256 %11 can be finally calculated as ( ( (2*10 + 5)%11 )*10 + 6)%11.
- So, the idea is to store the number
**N**in string**Str**. - Take a variable
**Num**, initialize it with 0. - Now iterate character by character over the string and convert it into a digit, starting from 0th index.
- Multiply your current
**Num**by 10 and add the current digit, say**b,**in it and then take it modulus with 11. So**Num**becomes**Num = (Num*10 + b)%11**. - The final value of Num will be the required remainder.

SIMILAR PROBLEMS

Longest Palindromic Substring

Posted: 4 Sep, 2022

Difficulty: Moderate

Cakes

Posted: 23 Sep, 2022

Difficulty: Easy

1-3 Palindrome

Posted: 4 Oct, 2022

Difficulty: Easy

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Co-Prime

Posted: 14 Dec, 2022

Difficulty: Hard

Popular Interview Problems: