Skip to content

Instantly share code, notes, and snippets.

@dansackett
Last active March 5, 2019 19:55
Show Gist options
  • Select an option

  • Save dansackett/6d0381ca3e81c05fbb82c7a1210faca5 to your computer and use it in GitHub Desktop.

Select an option

Save dansackett/6d0381ca3e81c05fbb82c7a1210faca5 to your computer and use it in GitHub Desktop.

Revisions

  1. dansackett revised this gist Mar 5, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion is_subset.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    /*
    Given a string "s1"
    eg. ABKHJDLNCMLNCKS
    @@ -9,7 +10,6 @@ eg. AKHJDMNS
    write a function that determines whether the characters in s2 are a subset of
    the characters in s1. (ie. are all of the characters in s2 also in s1)
    /*
    Note that this is a strict subset:
    so AAB is not a subset of ABCC
  2. dansackett renamed this gist Mar 5, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. dansackett created this gist Mar 5, 2019.
    30 changes: 30 additions & 0 deletions is_subset
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    Given a string "s1"

    eg. ABKHJDLNCMLNCKS

    and another string with a length equal to or less than s1, called "s2"

    eg. AKHJDMNS

    write a function that determines whether the characters in s2 are a subset of
    the characters in s1. (ie. are all of the characters in s2 also in s1)

    /*
    Note that this is a strict subset:

    so AAB is not a subset of ABCC
    AC, however, would be a subset, as would CA

    -it should take s1 as its first parameter, and s2 as its second
    -it should return true or false
    */

    function isSubset(s1, s2){
    // returns true or false
    }


    isSubset('ABCDEF', 'BE') // returns true
    isSubset('a', 'A') // returns false
    isSubset(' ABCDEF', 'FEDD') // returns false
    isSubset(' bac', 'c') // returns true