Why is Integer array [] preferred over an int array [] in java in competitive programming? Is there any difference in performance as one of my solution using the primitive int gave TLE while using the object array was AC?
-
The program contained only Arrays.sort(array) method apart from an O(n) algorithm.
-
Answer:
An integer array is preffered over an int array as integer is a wrapper class in java which helps us to store both characters and numerics.. it acts as an intermediate like in case of insertion of price in a text box where the values entered are treated like string.. and then converted to numeric equivalent.. this is not possible with int.. however it has a disadvantage.. the integer is a class in java and creates objects and memory is taken to instantiate all the class members and functions.. which is not the case with int.. hence it increases the execution time..
Karan Kapoor at Quora Visit the source
Related Q & A:
- What are some good competitive problems for a programming contest?Best solution by Programmers
- Why cannot we use static keyword inside a method in java?Best solution by Stack Overflow
- How to convert a char array into an int in C++?Best solution by Stack Overflow
- How to Convert a Procedural Programming into Object-Oriented Programming?Best solution by Stack Overflow
- How to hashMap an array in Java?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.