Geeks Talk

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.

Finding the rows and cols that have 1

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. ...

Go Back   Geeks Talk > Software Development > VB.NET
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

VB.NET Visualbasic.NET

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009
Junior Member
 
Join Date: Jun 2009
Location: San Francisco
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
wcmaggot is on a distinguished road
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.
Reply With Quote
Sponsored Links
Reply

  Geeks Talk > Software Development > VB.NET

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 03:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved