Giter Site home page Giter Site logo

consecutivenumberalgorithm's Introduction

Consecutive Number Algorithm

Code challenge from Kip at BTS

I'm admittedly not the HackerRank Greedy Algorithm guru. I've certainly had to create some algorithms over the course of my career, but generally speaking, very rarely experienced performance issues that a user found noticeable enough for a rewrite. Most performance issues would be something like not indexing a database table correctly for example.

Q&A From Email:

What pros/cons do you see with your solution?

The pros I see is that my solution works, and looks like reasonable tight clean code solution.

The cons I see are the possible use of Linq. When I have done some algorithms on HackerRank, it seems using code as close to assembly language as possible, whatever that would mean (i.e. arrary []), or what have you to reduce time. And techniques like recursion instead of for and foreach.

Suppose this needed to run on a machine with tight memory constraints. How could you reduce your memory consumption?

I think I tried to address this already by using LinkedList instead of List. From some basic research in this SO thread it sounds like List will have to keep expanding array size behind the scene as the data grows, which starts using more memory than LinkedList. If I did have to focus on memory constraints, I would look for a diagnostic tool to give feedback.

Suppose the system needs to support multiple sources of input e.g. an in memory list or an input file. How would you implement that?

I would create separate "front end" jobs that gather the respective data (one for reading memory list and another reading in file data), and have each "front end" job call this as a backend service to support DRY principles.

Suppose the list of numbers is streaming in from an external source (such as console input), and you should be able to look at any time and see the current list. Does your solution change and if so, what changes need to be made to allow for this?

No, I would use it as is. I created two methods that accept input to continue to add to the LinkedList of integers. The method is AddToLinkedList with signature ovveride allowing a single integer to be added, or a range of integer values.

consecutivenumberalgorithm's People

Contributors

jmarking avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.