Click here to Skip to main content
15,894,539 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: co-occurrence matrix Pin
Pete O'Hanlon14-Mar-17 23:47
mvePete O'Hanlon14-Mar-17 23:47 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan8-Mar-17 21:13
mveRichard MacCutchan8-Mar-17 21:13 
GeneralRe: co-occurrence matrix Pin
Member 1304545814-Mar-17 22:38
Member 1304545814-Mar-17 22:38 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan14-Mar-17 23:00
mveRichard MacCutchan14-Mar-17 23:00 
AnswerRe: co-occurrence matrix Pin
Patrice T9-Mar-17 15:16
mvePatrice T9-Mar-17 15:16 
GeneralRe: co-occurrence matrix Pin
Member 1304545814-Mar-17 22:32
Member 1304545814-Mar-17 22:32 
SuggestionRe: co-occurrence matrix Pin
CHill6015-Mar-17 1:08
mveCHill6015-Mar-17 1:08 
QuestionAlgorithm try and figure this out in c# Pin
Member 1300374315-Feb-17 11:28
Member 1300374315-Feb-17 11:28 
In some cities, the sewage system does not work properly and every time it rains, water accumulates on the streets and in between buildings, blocking traffic and causing distress.

You have an N number of buildings and an array with the height of every building.

You want to find out what is the maximum volume of water that would hypothetically accumulate after heavy rain, in between 2 buildings.

Input: N > 0 on the first line, array of N integer elements on the second line.

Output: integer positive X units of water.

Example: The following sequence of heights will generate the structure below:

Sequence: 1 2 1 5 2 4 1 0 1 2 6 4 5 2 3 4 1 2

The biggest block of water would contain 20 units of water.




<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace heavy_rain{
    class Program{
        static void Main(string[] args){
            System.IO.StreamReader sr;
            int n = 0, i = 0, result = int.MaxValue;
            int[] buildingHeights = null;
            try {
                sr = new System.IO.StreamReader(args[0]);
                String[] lines = new String[2];
                String line = null;
                while ((line = sr.ReadLine()) != null) {
                    lines[i++] = line;
                }
                n = int.Parse(lines[0]);
                buildingHeights = new int[n];
                String[] heights = lines[1].Split(' ');
                for(int j = 0; j < heights.Length; j++) {
                    buildingHeights[j] = int.Parse(heights[j]);
                }
                /* YOUR CODE HERE */
                Console.WriteLine(result);
            }
            catch (Exception e) {
                System.Diagnostics.Trace.WriteLine(e.Message);
            }
        }
    }
}

AnswerRe: Algorithm try and figure this out in c# Pin
Richard Andrew x6415-Feb-17 13:40
professionalRichard Andrew x6415-Feb-17 13:40 
AnswerRe: Algorithm try and figure this out in c# Pin
Richard MacCutchan15-Feb-17 21:20
mveRichard MacCutchan15-Feb-17 21:20 
AnswerRe: Algorithm try and figure this out in c# Pin
Richard Deeming16-Feb-17 2:02
mveRichard Deeming16-Feb-17 2:02 
AnswerRe: Algorithm try and figure this out in c# Pin
Patrice T18-Feb-17 14:59
mvePatrice T18-Feb-17 14:59 
QuestionProof by mathematical induction Pin
Member 129868787-Feb-17 0:18
Member 129868787-Feb-17 0:18 
AnswerRe: Proof by mathematical induction Pin
Pete O'Hanlon7-Feb-17 0:42
mvePete O'Hanlon7-Feb-17 0:42 
SuggestionRe: Proof by mathematical induction Pin
Richard MacCutchan7-Feb-17 1:46
mveRichard MacCutchan7-Feb-17 1:46 
AnswerRe: Proof by mathematical induction Pin
Chris Losinger7-Feb-17 8:46
professionalChris Losinger7-Feb-17 8:46 
AnswerRe: Proof by mathematical induction Pin
Patrice T8-Feb-17 6:27
mvePatrice T8-Feb-17 6:27 
QuestionTrapezoid shaped movement (updated with the newest code and status) - SOLVED Pin
Joan M5-Feb-17 22:12
professionalJoan M5-Feb-17 22:12 
AnswerRe: Trapezoid interpolation Pin
Ralf Meier6-Feb-17 0:23
mveRalf Meier6-Feb-17 0:23 
GeneralRe: Trapezoid interpolation Pin
Joan M6-Feb-17 21:47
professionalJoan M6-Feb-17 21:47 
AnswerRe: Trapezoid interpolation Pin
Ralf Meier7-Feb-17 0:00
mveRalf Meier7-Feb-17 0:00 
GeneralRe: Trapezoid interpolation Pin
Joan M7-Feb-17 0:54
professionalJoan M7-Feb-17 0:54 
GeneralRe: Trapezoid interpolation Pin
Ralf Meier7-Feb-17 1:25
mveRalf Meier7-Feb-17 1:25 
GeneralRe: Trapezoid interpolation Pin
Joan M7-Feb-17 3:10
professionalJoan M7-Feb-17 3:10 
GeneralRe: Trapezoid interpolation Pin
Ralf Meier7-Feb-17 6:57
mveRalf Meier7-Feb-17 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.