We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
What's the reason for using two loops and an array? I feel like that just takes too much time and too much space. Here's my take in C if anyone's interested:
but if we intializing array in long type after then we are inputing it and summing it then it is showing runtime error.. can you tell me why this happening or i am wrong??
A Very Big Sum
You are viewing a single comment's thread. Return to all comments →
I tried it in pure C ...a world of pain! But here's the answer
int main(){ int n; long bign = 0; long bignn; scanf("%d",&n); long arr[n]; for(int arr_i = 0; arr_i < n; arr_i++){ scanf("%li",&arr[arr_i]); } for(int arr_i = 0; arr_i < n; arr_i++){ bign = bign + (arr[arr_i]) ; } printf("%ld\n", bign); return 0; }
wow!
cool!! was missing 'li' and 'ld' in the scanf statements...'l' for long..!! thank you.
Thanks!
not working
What's the reason for using two loops and an array? I feel like that just takes too much time and too much space. Here's my take in C if anyone's interested:
see full and easy to understand code on:
https://github.com/akkshaychauhan/hacckerank-code/blob/master/Algorithms:A%20Very%20Big%20Sum
Not working ...is there any place where I can see answers ?
https://github.com/akkshaychauhan/hacckerank-code
Try long long int in place of int if you are using c
take value as value[] it will surly work.
you can check out the below link for video explanation :)
https://github.com/Java-aid/Hackerrank-Solutions
thanks buddy , i learned something from your program :-)
I am glad to know that my work helped you in your learning.
thank you it worked
but if we intializing array in long type after then we are inputing it and summing it then it is showing runtime error.. can you tell me why this happening or i am wrong??
I want to use functions in it . Can you give me the idea of it.
you can check out the below link for video explanation :)
https://github.com/Java-aid/Hackerrank-Solutions
It will only run for numbers less than 10 digit not more than that.
"a world of pain" - completely agree with you.
Does this work if you put the sum part under that function they have provided
THanks dude