Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Finding the rows and cols that have 1 within the VB.NET forums, part of the Software Development category; You have a matrix... private int[][] myMatrix; each cell will only contain 0 or 1. You need to find which columns and which rows contain at least one 1. i.e. ...
|
|||||||
|
|||
|
Finding the rows and cols that have 1
You have a matrix...
private int[][] myMatrix; each cell will only contain 0 or 1. You need to find which columns and which rows contain at least one 1. i.e. 'cols 3,6 and 9 have at least one 1 and rows 2,7 and 10 have at least one 1' I ran into this one about two years ago during an interview and they were trying to trip me up I am sure...the obvious (psudocode) for ( int row = 0 ; row < myMatrix.length ; col++ ) { for ( int col = 0 ; col < myMatrix[row].length ; col++ ) { if ( myMatrix[row][col] == 1 ) { 'save row is some result set and save col is some other result set'; } } print the two result sets; I am sure this is not the answer unless they were just trying to see if I know how to iterate a 2 dim array. There must be some clever algorithm that is very fast for this. |
| Sponsored Links |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| can we lock rows of a table so that not any instance can even select that rows? | UditaOra | Oracle | 3 | 07-31-2008 08:32 AM |
| how to move the particular rows or multiple rows in gridview are selected using check | gnanadesigan.k | ASP.NET | 1 | 07-18-2008 08:39 AM |
| Try finding the code | christia | Brainteasers | 2 | 04-09-2007 07:36 PM |
| Try finding out | nancyphilips | Brainteasers | 2 | 09-09-2006 03:02 PM |
| Finding Your First Job - Self-Assessment | admin | Interviews | 0 | 05-27-2006 11:11 AM |