Finding duplicate entries in an int[]

Okay, So I need to solved the following problem.
Given an int[] or Integer[] with 1,000,000 entries. There are 2 entries out of the 1,000,000 that are duplicate. I need to find and return the duplicate entry.
Obviously iteration is out of the question given the size of the array, and converting to an arraylist would likewise not help alot.
Please offer any suggestions

well I tried this....
public class Main
     public static void main(String[] args)
          int list2[] = new int[1000000];
          for (int i=0; i < 1000000; i++)
               list2[i] = i;
          System.out.println(getDouble(list2));
     public static int getDouble(int[] intArray)
          ArrayList<Integer> list = new ArrayList<Integer>();
          for (int i=0; i < intArray.length; i++)
               list.add(intArray);
          for (int i=0; i < list.size(); i++)
               Integer a = list.get(i);
               if (list.indexOf(a) != list.lastIndexOf(a))
                    return list.get(i);
          return 0;
}and it takes forever.  So if you have a really fast way, a hint would be nice :-).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Finding duplicate entries in address book

    I am using Address Book 5.0.3, where I have been using LinkedIn's CardMunch to import contact details via my iPhone. However, I now end up with three distinct issues regarding duplicate entries:
    1/ two people with the same name, e.g. John Smith, but I know they are two separate people and they work for different companies.
    2/ After an import, I may have some duplicate entries, say Alan Walker, who has moved from company A to company B and I want to replace his old contact details with the new information.
    3/ two duplicate entries the same name, say Brian Vickers, both of which refer to the same person who still works for the same company, but has new contact details or additional data, such as a mobile number that I did not have before.
    4/ two duplicate entries that are identical. E.g. I imported the same card twice for some reason.
    5/ multiple entries marked 'Cannot Read Name', where CardMunch had a problem, but I know they are different people and I have to edit these to manually enter the correct information.
    Unfortunately the Address Book find duplicates function, whilst it works, does nothing useful. The only option I am presented with is 'Merge', which in all of the scenarios above apart from item 4 I do not want to do a merge function - I want to either 'Mark as NOT Duplicates' (item 1/), 'Replace Selected Fields' e.g. show me the two cards side by side and allow me to select which fields from which card are to be kept, replaced or removed and then implement the merge (item 2), "Add New Information' but allow me to select the label for that information before merging so that if someone has a new iPhone, but is still keeping their old mobile, I can select the field label correctly and then merge (item 3) or 'Edit Card' which allows me to open any identified duplicate and add in missing information that would mean that it is no longer a duplicate item.
    Can anyone suggest a way of doing this, or can Apple's developers please add these features to the Address Book App as soon as possible?
    Thanks, Russ Taylor

    books06,
    Welcome to Apple Discussions.
    It depends upon which version of Address Book you are using, and your definition of "view."
    1. Address Book 3.1.1 Help
    2. Address Book 4.0.3 Help: Combining duplicate cards and information
    To find and merge duplicate cards:
    1. Choose Card > "Look for Duplicate Entries."
    2. Address Book tells you if it finds duplicate cards, cards containing duplicated information, or both.
    3. Click Merge to merge duplicate cards and remove redundant information on cards.
    When Address Book merges duplicate cards, it creates a single card for the contact containing all of the unique information from each merged card. Address Book uses the picture from the merged card appearing first in the list.
    To merge selected cards only, Command-click to select the cards you want to combine and choose Card > Merge Selected Cards. Address Book creates a single card using the name and picture of the selected card appearing first in the list.;~)

  • Help needed in finding duplicate entries in invoices

    Hi,
    let me explian u the senario.
    when we enter the invoice no. in vf03 and select any item and click on pricing button.
    there i find the Cnty fild having duplicate entries like xr1 2 times and xr2,xr3,xr4,xr5 and xr6 all 2 times
    so i need to write a query to find out which of all the invoices have these types of duplicate entries.
    regards,
    maqsood

    Hi!
    CnTy is header line of condition type column.
    There can be several reasons, why conditions types are twice in a document. E.g. conditions can be given on header and line level, so they are two times in a document.
    These tax conditions are just line level. But please check, if they have different colors. I currently don't remember if only the blue or only the black lines (with or without highlight) are relevant for the document.
    The inactive conditions are still shown, but not 'counted'. You can set conditions inactive by requirements, by formula, by exclusion groups... so there are many ways to set the system up.
    Only if your total is wrong you have to do something (e.g. give users a training how to create a sales order / invoice).
    Conditions for invoice can be found in KONV with KONV-KNUMV = VBRK-KNUMV.
    Regards,
    Christian

  • Finding Duplicate Entries in a table

    I have a table with the following fields in Oracle 10g.
    TABLE_1
    account_no | tracking_id | trans_amount
    Each account_no can have multiple tracking Id's.
    How do i query out the duplicate entries of account_no where tracking lies between 1 and 1000 ?
    Many thanks in advance for your help,
    novice.

    Hi,
    Whenever you have a question, it helps to post a little sample data, and the results you want from that data.
    You may think you're explaining clearly, but it won't be nearly as clear to someone who isn't familiar with your tables, your data, and your requirements. Sanjay and I apparantly have different ideas about what you requested, and perhaps neither is what you really want. It would be much harder for us to make mistakes and give you bad advice if you posted the data and results.
    Here's my guess:
    WITH     got_cnt     AS
         SELECT     table_1.*
         ,     COUNT (*) OVER (PARTITION BY account_no)
         FROM     table_1
         WHERE     tracking_id     BETWEEN     1
                        AND     1000
    SELECT     account_no, tracking_id, trans_amount
    FROM     got_cnt
    WHERE     cnt     > 1
    ;If there are two rows with the same account_no, and both rows have tracking_id in the given range, then both rows will be displayed.

  • Finding duplicate entries in pages doc...

    i've got a huge pages document with email addresses.
    is there a simple way to scan the document for dupes?
    anyone??
    thx!

    If the email addresses are all that is in the document, they are in a list, and you also have Numbers, the following will work:
    Select all of the list. Copy
    Launch Numbers and open a new, blank document.
    Click on cell B2 of the table in Numbers. Paste.
    Your addresses should fill column B, with rows added to the table as necessary.
    Enter this formula into C2: =IF(COUNTIF($B$1:B2,B2)>1,"DUP","")
    (The result in C2 should appear to be an empty cell.)
    Click on the Column Reference tab for column C to select the whole column,  then
    Command-click on cell C1 to remove it from the selection.
    Go Insert (menu) > Fill > Fill Down.
    Your table will now resemble this one, with duplicate entries marked in column C:
    With column C still selected, Copy, then go Edit > Paste Values.
    This replaces the formulas in column C with the values calculated by that formula.
    Click the Reorganize button, then in the Sort section, choose Column C.
    The table will be sorted, bringing all the DUP entries together at the top of the table.
    Select all of the rows containing DUP (Click on the Row Reference tab of the first, then shift-click on the Row reference tab of the last) to select all of the rows containing duplicate addresses.
    Go Table > Delete Rows.
    Select the column containing the email addresses. Copy.
    Return to the Pages document. Paste.
    Done
    Regards,
    Barry

  • How to find duplicate entries

    Hi
    I have table A contains 5 colums and doent contain any constraints and 1000 records are avaible
    I have table B contains 5 columns contain 500 records
    and table A and table B have same data types of columns
    now i want to insert table B rows to table A . If table A contain same rows of table B, should not insert table B rows.
    Please give me solution for with out using any contraints.

    942919 wrote:
    Hi
    I have table A contains 5 colums and doent contain any constraints and 1000 records are avaible
    I have table B contains 5 columns contain 500 records
    and table A and table B have same data types of columns
    now i want to insert table B rows to table A . If table A contain same rows of table B, should not insert table B rows.
    Please give me solution for with out using any contraints.Not sure why you despise constraints; But below could be a way (IMAGINARY & Un-Tested) since you chose not to provide us with Sample Tables and Data
    INSERT INTO table_a
    select col1, col2... coln
      from table_b b
    where not exists ( select 'x' from tabel_a a where a.matching_col = b.matching_col ) -- Your Matching Cols may increase, so adapt accordingly.Edited by: Purvesh K on Nov 23, 2012 4:20 PM

  • Middleware Settings - Duplicate entries in the Table TCURC

    Hi Experts,
    I am doing middleware settings for integrating SAP CRM 5.0 with SAP R/3 4.7.
    Before replicating the customizing objects, i found duplicate entries for ISO Codes in the table TCURC (Field name-ISOCD).
    Following are those entries
    MANDT     WAERS     ISOCD     ALTWR     GDATU     XPRIMARY     LTEXT     KTEXT
    949     CFP       XPF       953       00.00.0000          French Franc (Pacific Islands)     Fr. Frank (Pac)
    949     CNY       CNY       156       00.00.0000     X     Chinese Renminbi     Renminbi
    949     DEM       DEM       280       00.00.0000     X     German Mark     German Mark
    949     DEM3      DEM       280       00.00.0000          (Internal) German Mark (3 dec.places)     (Int.) DEM 3 DP
    949     RMB       CNY       156       00.00.0000          Chinese Yuan Renminbi     Yuan Renminbi
    949     USD       USD       840       00.00.0000     X     United States Dollar     US Dollar
    949     USDN      USD       840       00.00.0000          (Internal) United States Dollar (5 Dec.)     US Dollar
    949     XPF       XPF       953       00.00.0000     X     CFP Franc     Franc
    Duplicate entries are in the third column.
    Please kindly let me know what is the impact and what should i do now.
    Points will be rewarded for the helpful answers.
    Thanks in advance
    Nadh.R

    Hi Murali,
    Thanks for your reply.
    But i didnt find anything related to the issue in that note.
    Do you have any other solution.
    Thanks
    Nadh.

  • How to delete duplicate entries in address book

    Is there an easy way to delete duplicate entries in Address Book?

    I have an iPhone where I create new contact details and a MB Air running OX X 10.7.3
    In Address Book I see duplicate entries across the whole book. The other day I was traveling without my MB and needed to urgently reach someone who's number I knew was in my iPhone contact list for sure but searched and search and couldn't find it.
    Turns out that when I had been going through the Adress Book on the MB Air trying to eliminate some of the duplicates I had chosed --without even knowing it or realzing it-- the card that I guess sync with my iPhone. It was gone. Sure enough, when I got back and looked it up on the MB Air it was still there not syncing to my iPhone.
    I have used Address Book / Card / Look for Duplicates ...
    I have also followed the Help suggesting and pressed Control / select to highlight two duplicate cards and even though the First / Last / Company / phone numbers / etc. are all the same I get the message: "The cards could not be merged because they came from different accounts."
    I have checked with guys from the office who have the exact same problem with no idea how to solve the problem.
    Is it that in order to use Address Book on both an iPhone and an OS X machine you've just got to be smarter, more sophisticated, more IT oriented?
    Seems like a pretty easy thing not to be struggling with.
    I should mention that I was a Mobile Me subscriber and now use iCloud which I'm sure has something to do with all of this.
    But it seems pretty basic to me. If I have an Address Book it should synchronize between OX X and IOS.

  • View Duplicate Entries in Address Book

    Does anyone know how you can view your duplicate entries in Address Book before you merge them?
    Thank you!

    books06,
    Welcome to Apple Discussions.
    It depends upon which version of Address Book you are using, and your definition of "view."
    1. Address Book 3.1.1 Help
    2. Address Book 4.0.3 Help: Combining duplicate cards and information
    To find and merge duplicate cards:
    1. Choose Card > "Look for Duplicate Entries."
    2. Address Book tells you if it finds duplicate cards, cards containing duplicated information, or both.
    3. Click Merge to merge duplicate cards and remove redundant information on cards.
    When Address Book merges duplicate cards, it creates a single card for the contact containing all of the unique information from each merged card. Address Book uses the picture from the merged card appearing first in the list.
    To merge selected cards only, Command-click to select the cards you want to combine and choose Card > Merge Selected Cards. Address Book creates a single card using the name and picture of the selected card appearing first in the list.;~)

  • Have iTunes version 10 .3 but do not understand cloud in iTunes 11.03 can someone explain it and also how do you find duplicates in new version and will the new version sync with my iPod Classic which I have had for 4 years

    I have iTunes version 10.03 which I love but my iPad Apple mini has iOS 7 but I don't understand the new iTunes what is the cloud shown next to the music and how can I find duplicates can anyone help me navigate the new iTunes and will the new version sync with my iPod Classic which is 4 years old

    The main differences between iTunes 11 and earlier versions are the loss of coverflow and ability to have multiple windows open.
    In Windows, you can restore much of the look & feel of iTunes 10.7 with these shortcuts:
    ALT to temporarily display the menu bar
    CTRL+B to show or hide the menu bar
    CTRL+S to show or hide the sidebar
    CTRL+/ to show or hide the status bar (won't hide for me on Win XP)
    Click the magnifying glass top right and untick Search Entire Library to restore the old search behaviour
    Use View > Hide <Media Kind> in the cloud or Edit > Preferences > Store and untick Show iTunes in the cloud purchases to hide the cloud items. The second method eliminates the cloud status column (and may let iTunes start up more quickly)
    If you don't like having different coloured background & text in the Album (Grid) view use Edit > Preferences > General and untick Use custom colours for open albums, movies, etc.
    With iTunes 11.0.3 and later you can enable artwork in the Songs view from View > Show View Options (CTRL+J) making it more like the old Album List view
    View > Show View Options (CTRL+J) also contains options to change the sorting of grid based views
    The cloud icons give you access to stream or download any qualifying past purchases that you don't currently have downloaded to the library.
    Regarding duplicates, things haven't really changed. Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin. Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    Yes, iTunes 11 will support your iPod classic.
    tt2

  • Missing and duplicate entries in the calendar

    I'm a long time (1997) Palm user who's moved to a BB 8330 last month. I can't seem to get calendar syncing to work correctly. In some instances, I am missing items on Outlook. I often have duplicate entries on the handheld. I've searched the forums and there seem to be similar issues and the solutions appear to be around Service Books, but I'm not confident I have a clue how not to lose lots of info.I also cannot seem to find information that explains the relationship between email addresses & calendar (I don't see why there should be any!!!)
    Scenario (trying to answer up front the questions from other forum posts):
    I am using Outlook on my home computer to manage my personal calendar. I do not have an email account associated with Outlook.I have set up 2-way sync with Outlook for calendar, tasks & contacts
    My work uses Lotus Notes. I have set up one sync to the handheld only from the Lotus Notes calendar
    The only email account configured on the BB is a gmail account (which is not associated with either calendar). I originally set this up via the wizard, then removed it, but added it back (under Email settings) when I discovered I couldn't send email from the Address book without it. I actually prefer google mobile for email management since it modifies the server state as well. Not sure if the add/remove/add sequence has somehow messed up the calendar?
    I have checked under Calendar > Options and two calendars appear. Based on the color associations it appears that Device Default is associated with Outlook personal calendar & my gmail account is associated with the Lotus Notes calendar entries. As far as I know I did not create these associations. 
    Checking under Options > Advanced Options > Default Services, I see CICAL & CMIME entry and those are both the gmail account.
    Checking under Options > Advanced Options > Service Book, I see only one CICAL & CMIME entry and those are both the gmail account.
    Separately, I do have a couple of mobile apps to read email (gmail- same acct - and yahoo), but those appear to not integrate into the BB apps directly. 
    Everytime I sync with Outlook, I end up with lots of duplicate entries on the handheld. I have also noticed that I am missing entries that are on the handheld, but are not on Outlook (in one very odd case, the entry was created on Outlook and now only exists on the handheld). I may have deleted duplicate entries related to the missing items at one time... I can't be sure about that. I believe I currently have a complete calendar on the handheld, but not 100% confident I have a good calendar anywhere. 
    And as an aside, have to say I'm really bummed that I have lost easy access all my Palm historical data. It appears BB will not bring in old calendar data by design (found that in some BB documentation on their site).  Now that I will not keep up with Palm upgrades, at some point I will lose access to that data. Sigh. 
    Any, all help appreciated.  

    Hello...correction:
    RaviStrs wrote:
    Ok. In that case, try this. (That worked for me when I had similar problem. Ignore if you already tried this)
    1) Turn off the phone
    2) Remove the battary and place it again
    3) Restart your phone
    Have the BB ON (e.g., something showing on the display, the HomeScreen would be fine) when you remove the battery. That is the cleanest hard reboot method.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Duplicate entries in loop browser

    Have just bought a new iMac and running GB '08. When I moved my old loops over from my old machine via an external hard drive, I now have duplicate entries of all the loops in the browser. Any ideas on a fix?

    so next question: where do i find the factory loops that are in gb if i want to delete them?
    http://www.bulletsandbones.com/GB/GBFAQ.html#looplocation
    or is that even possible?
    as long as you reindex the browser to get rid of the links to them.
    if i now want to bring in some of my own loops from the other computer, do i need to trash the indexes again and drag the new loops in
    as long as they're not dupes, no.
    or can i just drag them in now?
    yes

  • How do I find duplicate words in a Numbers spreadsheet?

    Hello, I've created my first document on Numbers and am trying to figure out how to find duplicate words. Ideally, a list of words that repeat in the document and how many times. Is this possible? Thank you in advance for the advice

    It's easy enough to find and count duplicate entries, especially if they are all in a single column, but if you want to count individual words within multi word entries, the problem is more complicated.
    Here's an example for the 'simple' case, using a familiar 155 word passage from English literature.
    The words in the passage are separated into a single line for each word, and stripped of all punctuation. This may be done in Pages, or in Text edit, or in pretty much any word processing software or text editor. Paste the passage into a WP or text document, then use the application's Find/Replace feature to replace all of the spaces with returns. I would also do a second pass replacing all double returns with single returns, then repeat that until Find/Replace reported replacing zero occurrences.
    Punctuation was stripped using Find/Replace
    The prepared list was pasted into column A of a Numbers table.
    Formulas:
    B2: =COUNTIF($A$1:A2,A2)
    C2: =IF(AND(B>1,B=COUNTIF($A,A2)),ROW()-1,999999)
    Fill both down their respective columns to the end of the table.
    The small table is inserted as a Basic table using the Tables button. It contains a Header row, but no Header columns.
    Formula:
    A2: =IFERROR(OFFSET(Table 1 :: $A$1,SMALL(Table 1 :: $C,ROW()-1),COLUMN()-1),"")
    Fill right into B2, then fill both down to the end of the table.
    Descriptions of the functions used, along with their syntax and at least one example of their use in a table are available in the Numbers '09 User Guide, which may be downloaded via the Help menu in Numbers.
    Regards,
    Barry
    PS: Regards to the late Mr. Shakespeare, and thank you for providing the text used.

  • Duplicate Entries in Library

    In the process of trying to move my itunes library to an external drive, I've ended up with duplicate entries for each file. Both entries play the same file, but when one entry is deleted from the library, the file gets deleted, and the remaining entry does not play. How do I remove one of the duplicate entries without deleting the file?

    It seems there's only one library - on the external drive. Before I moved my library, I looked in itunes help to figure out how to do it properly, and never really got a clear answer, so I just copied and pasted my files onto the external drive, then deleted the original library off the internal drive, and things went from bad to worse from there. Everytime I consolidate the library, it just seems to duplicate everything, not really solving the problem. It's not a question of duplicate files - it's more a question of duplicate listings/entries for the same single file so that if I delete the wrong entry/listing from the library, the remaining listing can't find the file to play, because I've just unwittingly deleted the music file.

  • Right Click Move menu has duplicate entries

    One of my users frequently sorts mail into subfolders on a shared mailbox. They most commonly do this by right clicking the message, selecting Move, then selecting the folder. 
    Somehow, they ended up with a duplicate entry in the right click menu. In other words, the folder "October 2014" appears twice in the list.
    The first question is: how can the duplicate entry be removed?
    Secondly, one of these menu items works. When it is selected, the message can then be found in the "October 2014" as expected. The other of these menu items does not work. When it is selected, the mail is no longer in it's original location (inbox,
    etc.) but  also does not appear in the "October 2014" folder. Searching her mailbox (even searching all of Outlook) returns no results when searching for a message moved this way. I've
    also used Get-mailboxfolderstatistics to examine the folder structure of both her account and the shared mailbox account. Only the one folder named "October 2014" appears to exist.
    Second question: How can I find where messages moved with the duplicate entry were moved to? How can I move them to the correct folder?

    Hi,
    Do you mean there is a duplicate entry in the Move To Folder history that you see when selecting
    Move?
    We can try to clear the Move To Folder history to check the result. To do this, please follow:
    1. Exit Outlook.
    2. Open your Registry Editor and navigate to:
    Outlook 2013
    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles\profile name\0a0d020000000000c000000000000046
    Outlook 2010 or previous on Windows NT, 2000, XP, Vista, Windows 7 or Windows 8
    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\profile name\0a0d020000000000c000000000000046      
    3. Find the registry value named 101f031e.
    4. Rename or delete the value and restart Outlook.
    Now, the Move To Folder history will be cleared and next time you move a email to a folder, Outlook will add the entry to the history again.
    For the second question, how did the user add the shared mailbox in his Outlook? Please note that in some configurations, you are limited to using the
    Current Folder search scope when searching in a shared mailbox. Please try to directly login to the shared mailbox and then search for the disappeared emails. Please let me know the result.
    Hope this helps.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

Maybe you are looking for