GithubHelp home page GithubHelp logo

mod-1-whiteboard-challenge-move-zeroes-and-two-sum's Introduction

web-week-2-cs-problem

For the next 30 minutes take turns with the person sitting next to you whiteboarding out solutions to the two following problems. Try to only use Ruby documentation as an outside resource.

Problem1

"Given an array of numbers, write the method move_zeroes() method to move all 0's to the end of it while maintaining the relative order of the non-zero elements.

For example, given nums = [0, 1, 0, 3, 12], after calling your method, nums should be [1, 3, 12, 0, 0].

def move_zeroes(nums)

end

Array sorted before and after

Problem2

"Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

The method two_sum should return the indices of the two numbers such that they add up to the target, where index1 must be less than index2.

You may assume that each input would have exactly one solution.

Input: numbers=[2, 7, 11, 15], target=9 Output: {index1: 0, index2: 1}"

def two_sum(numbers, target)

end

mod-1-whiteboard-challenge-move-zeroes-and-two-sum's People

Contributors

drakeltheryuujin avatar jjseymour avatar maxwellbenton avatar mmacdonald1 avatar rrcobb avatar thuyanduong-flatiron avatar timothylevi avatar

Watchers

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