The problem FALSNUM states that:

- The first line contains an integer T, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, an integer A.

I used the correct logic and got WA on every submission. After the solutions were made public, I checked the AC submissions and all have taken **A as a string input**.

Can someone please explain me the reason? @cubefreak777 @sebastian @suman_18733097

number of digits in A can be upto 5000. no integer type variable can store that long number . so they used string

3 Likes

This means A \approx 10^{500} which is way more than the limits of int data type

4 Likes

If u ever see any question where they say u have to change some digit in a number which might be say bigger than 10^18 or so better use string

2 Likes

Yeah, as mentioned by @cubefreak777 , the constraints are pretty much high. It is better to take A as a String. There are many such problems where we take Big Integers into Strings. One of the best examples is the next permutation problem - Given an Integer N, you are allowed to swap the digits of N, find the next lexicographically smallest permutation, given that 1\le N\le 10^{10^6}.

1 Like

I have a doubt in one question, will anyone please help?

Where is this formula used?

left_tree (data) <= node (data) <= right_tree (data)

Binary tree or BST or AVL Tree or Heap

I was confused between AVL and BST as an AVL is also BST.

AVL is BST that self-balance.

Hey I did the same mistake as you and wasted about an hour trying to solve the problem. But the range of no of digit given in the question is way to big for any int to store so you got to use string to hold that data.