Show Some Love

merge two big Lists in one sorted List (java)

This forum was posted on Sunday, May 19, 2013 8:25:15 PM

I had an interview today and they gave me:
List A has:


List B has:

They asked me to merge these two list in one sorted List C.
What I told:
I added List B to List A then I made a Set from List A then generate a List from the Set.
he said me the list are big and this method will not be best for performance he told it will be a nlog(n).
Plz any concept How can i approach this issue ?

50 Viewed this Question

 Recent Replies on "merge two big Lists in one sorted List (java)"

  • Nobody has replied on this post, be first to post answer.

Post Your Solution for this Question

Note: Please Put Code into <code></code> block.

Threads related to "merge two big Lists in one sorted List (java)":

SocketTimeoutException while testing JSF app on glassfish with Jmeter (single user thread & jmeter+server both on same machine)

While testing my JSF2(myfaces) web application with JMeter I get the following exception (logged by JMeter). (there're no errors logged in Glassfish logs & app runs best in browser otherwise) Read timed out at Method) at Source) at Source) at Source) at Sou

What would cause MMS to time out trying to access a specific IP and port?

I hv been trying to get MMS to work in CM9 on and it is consistently timing out when trying to connect to port 81. Plz see the logcat below from sending a MMS. E/Mms:transaction( 1402): Url: 1402): Connect to / timed outE/SendTransaction( 1402): Connect to / timed outE/SendTransaction( 1402): at

Java compiler error: lookup table exceeds 65535 limit

I'm running into this compiler error due to my extremely large lookup table based on this definition://92 X 182 arrayprivate static final double lookUpTable = new double{ { numbers....}};As i understand it dividing it up is a solution but it would be extremely typical to split this array up accurately. I also believe i could move it out to a file but i don't know if i could format it in a approach to Plz Please help me in this in this plus i don't want file reads every second.Are there any other solution t

Cannot Match A X.509 CN With A Java Regular Expression

I'm trying to use a Regular Expression to match a CN from an X.509 certificate. The entire string will appear something like this:CN=JASON OU=MYOU O=MYORGhere is the nonworking code snippet snippet: Object certChain = request .getAttribute("javax.servlet.request.X509Certificate"); String name = ""; if (certChain != null) { X509Certificate certs = (X509Certificate) certChain; X509Certificate cert = certs0; name = cert.getSubjectDN().getName(); } String strPattern = "CN=(.*?

Failure to initialize GregorianCalendar Object

I'm a complete fresher with Java and I hv been making simple test-programs to review little of the material I read. The following block of code snippet snippet works incorrectly. it's supposed to accept a Year Month and Date from the user and then generate a GregorianCalendar object initialized with the year month and date. However Whenever I try to return the GregorianCalendar variable's month it generally returns the month I initialized the month variable with. I'm not sure why. import jav

Can only reference properties of a sub-object if the sub-object is embedded

i wish to recover data by the parent key with datanucleus on Google AppEngine. I use JPA.Here is my Stock bean (the parent):@Entitypublic class Stock implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key key; @OneToMany(fetch=FetchType.LAZY mappedBy="stock") private List stockValues;}Here is my StockValue bean (the children):@Entitypublic class StockValue implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private

Segmentation fault (core dumped) on Server side in CORBA C++/Java application

I hv such code snippet snippet:interface Employee{ string getLastname();};#include "Employee.idl"interface Work{ Employee getEmployee(in short id);};Server files:#include "Employee.hh"class EmployeeImpl : public POA_Employee{ private: char* lastname; int id; public: EmployeeImpl(const char* lastname int id); char* getLastname();};#include "EmployeeImpl.h"EmployeeImpl::EmployeeImpl(const char* lastname int id){ this->lastname = const_cast(lastname); this->id = id;}char* E

Exception “java.awt.color.CMMException: Invalid image format” thrown when resizing certain images…why?

After obtaining an image from DB Whenever I try to resize it by passing width using the below code snippet snippet public static BufferedImage resize(final byte pImageData final int width final int height final int maxLength final int minLength final String imageSubType) throws Exception { InputStream is = null; BufferedImage resizeImageJpg = null; try { is = new ByteArrayInputStream(pImageData); BufferedImage originalImage =; -------------------- } }The following excepti

Given a length and a set of characters, how to get all the possible string combinations duplicate

Possible Duplicate: generating all permutations of a given string Given a length n=4 and a set of characters -> {'a' 'b'} How do I write little java codes to produce all the possible string with that length n containing the characters in the set?For the illustration above the solution should have 2^4=16 strings which is:aaaaaaabaabbabbbbaaabaabbabbbbbbbbaabbabbbbaabaaabababbababaaabahere is my code snippet snippet snippet:public void process(String solution String string){ if(string.length() ==

Spring 3.1.1 MVC Model behaviour vs ModelAndView behaviour

Input conditions:Spring 3.1.1Enum SomeEnum (without overriden toString() method)Formatter for that enumSpring postHandle interceptor Controller that uses the enum (actually inside other class so no issues here) as @ModelAttributeView that uses Spring form select tagWhen I put SomeEnum object into Model (inside controller) spring form select tag uses name() method of SomeEnum for option value and Formatter.print() method for option text. This is what I expect from Spring :)But when I put SomeEn