×

# Alternate way of storing data of array size 10^9

 0 My program is giving runtime error when i exceed my array size beyond 10^7 , can anyone help me to solve this issue :) asked 15 Nov '15, 11:40 87●1●4●13 accept rate: 0%

 5 Then you should find another algorithm for the problem. You may consider the following things: The array of size 10^9 takes 100 times more memory than 10^7 size array. Considering it an int array, this array alone will take memory of around 3800MB. Most problems do not allow this amount of memory. Even if you're able to declare an array of such great size, You won't be able to apply a linear time algorithm in many of the problems as it will probably exceed the time limit. To get a hint of the approach, you can look at other solutions' memory and execution time. If the required array in the problem requires such an array, but it would be sparsely filled, then you may consider hashing. answered 15 Nov '15, 12:14 1.1k●1●8 accept rate: 10% 1 If it is a contest problem, remove the solution link as soon as possible! As for the approach, you'll find much smarter solutions, once the contest ends. (: (15 Nov '15, 12:48) Got ur idea i ll try finding some other approach :) (15 Nov '15, 12:59) 1 In your situation, point number 3 will surely help you out (15 Nov '15, 13:08) okk @ xariniov9 (15 Nov '15, 13:17) i found others are also doing the same mistake and got 25 points but in next 4 minutes they got 100 points , how can they do this :p (15 Nov '15, 13:20) Got it complexity will be O(1) (15 Nov '15, 13:21) showing 5 of 6 show all
 1 i think you are trying to solve EGRKAKE..you can do it with very simple trick...now recognize that TRICK by your self answered 15 Nov '15, 13:12 72●3 accept rate: 7%
 0 Declare array as global i.e. before int main(). answered 15 Nov '15, 12:56 983●14 accept rate: 11%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

question asked: 15 Nov '15, 11:40

question was seen: 518 times

last updated: 15 Nov '15, 13:59