GithubHelp home page GithubHelp logo

algorithm's Introduction

algorithms

Discovering Issues

step1: Find a problem that you would like to work on under the Issues Section. Each problem has a difficulty label and description of the input and the expected output.

Setup

step1: Fork repository!

step2: Clone your repository

step3: To install all of the dependencies, run npm install

algorithm's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

algorithm's Issues

Lesson 2: xpair

Takes in an array and a number and returns true if any of the pairs adds up to the number.

Input: ([1, 1, 2, 4, 5], 3)
Output: true

Sum2

Input: a number, a number
Return: Sum of the numbers

Input: 5, 6
Return: 11

Lesson 2: findStartLoop

Takes in a linkedList and returns true if the circular loop starts anywhere in the list.

Example 1: (linkedList starts at n1)

const n1 = { val: 'n1Val', };
const n2 = { val: 'n2Val', };
const n3 = { val: 'n3Val', };

n1['next'] = n2;
n2['next'] = n3;
n3['next'] = n2;

Input: n1
Output: true because the circular loop started somewhere in the list.

Example 2: (linkedList starts at n1)

const n1 = { val: 'n1Val', };
const n2 = { val: 'n2Val', };
const n3 = { val: 'n3Val', };
const n4 = { val: 'n4Val', };

n1['next'] = n2;
n2['next'] = n3;
n3['next'] = n4;
n4['next'] = n2;

Input: n1
Output: true because the circular loop started somewhere in the list.

Example 3: (linkedList starts at n1)

const n1 = { val: 'n1Val', };
const n2 = { val: 'n2Val', };
const n3 = { val: 'n3Val', };

n1['next'] = n2;
n2['next'] = n3;

Input: n1
Output: false because the circular loop does not start somewhere in the list.

nStr returns n string

Input: a string, a number (n)
return: the string repeated n times.

Input: "Apple",5
return: Apple Apple Apple Apple Apple

Lesson 2: map

Takes in an object and a function and calls the function as many times as there are key/value pairs with each key, value. It's like you're creating a forEach function for objects. For each key/value pair in the object, you'll be doing calling the function to each of those key/value pairs. Also, map is a native method in Javascript which means doing the same thing to every element in the array. So you're essentially writing a map method for objects!

Example 1:

const obj1 = {
     name: 'Maricris',
     age: 24,
};
const func1 = (key, value) => {
     console.log(`Key/Value Pair = ${key}: ${value}`);
};
Input: (obj1, func1)
Output: 
Key/Value Pair = Name: Maricris
Key/Value Pair = Age: 24

Example 2:

const obj2 = {
     curriculum: 'HTML',
     challenges: 3,
     students: 'Kinue + Saumya +Amey',
     level: 5,
};
const func2 = (key, value) => {
     console.log(`Key/Value Pair = ${key}: ${value}`);
};
Input: (obj2, func2)
Output: 
Key/Value Pair = curriculum: HTML
Key/Value Pair = challenges: 3
Key/Value Pair = students: Kinue + Saumya + Amey
Key/Value Pair = level: 5

Lesson 2: repeatingElements

Takes in an array of numbers and returns an array of all duplicate numbers. Hint: Use an object to keep track of which numbers are repeated.

Input: [1, 2, 2, 3, 3, 3, 4, 5, 5]
Output: [2, 3, 5]

Max 3

INPUT: number, number, number
RETURN: the biggest one.

INPUT: 5,8,9
RETURN: 9

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.