How to remove duplicate rows from the matrix

Source: Internet
Author: User

There is a matrix in the form of a two-dimensional array. There are numbers and strings in each row of the matrix. How do I remove the same rows? The same row indicates that the values at all latitudes are the same.

The solution I came up with is as follows:

Concatenate the values of each row into a string and use the index of the row vector as the key. The time complexity should be O (n ). Traverse hashtable to obtain the corresponding index, that is, the number of the remaining rows after repeated entries.

Is there a better solution to the matrix of pure numbers?

 

Supplement: Find a new solution using the dataview method:

  1. // Remove the dataview of the duplicate row
  2. Dataview mydataview = new dataview (datatable );
  3. String [] strcomuns = {"datacolumn", "datatype "};
  4. Dg2.datasource = mydataview. totable (true, strcomuns );

Datacolumn and ype are data column names in the datatable. The first parameter of the totable method specifies whether to remove duplicate rows, and the second parameter specifies which columns are used to determine whether duplicate rows exist.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.