      "## Algorithm: List\n",
      "\n",
      "![alt text](https://raw.githubusercontent.com/donnemartin/algorithms-data-structures/master/images/compress_string.jpg)\n",
      "\n",
      "Since Python strings are immutable, we'll use a list to exercise array manipulation.  Note using a list vs a bytearray will will result in additional space to create the list and to convert the list to a string.\n",
      "\n",
      "* If string is empty return string\n",
      "* count = 0\n",
      "* size = 0\n",
      "* last_char = first char in string\n",
 
</s> remove     "Since Python strings are immutable, we'll use a bytearray to exercise array manipulation.  We could use a list of characters to create the compressed string then convert it to a string in the end, but this will result in additional space.\n",
 </s> add     "Since Python strings are immutable, we'll use a bytearray to exercise array manipulation.  As seen above, we could use a list of characters to create the compressed string then convert it to a string in the end, but this will result in additional space.\n", </s> remove     "* If bytearray is empty return bytearray\n",
    "* count = 0\n",
    "* size = 0\n",
    "* last_char_code = first char code in bytearray\n",
    "* For each char code in bytearray\n",
    "    * If char code == last_char_code\n",
    "        count++\n",
    "    * Else\n",
    "        size += 2\n",
    "        count++\n",
    "        last_char_code = char code\n",
    "* size += 2\n",
    "* If the compressed bytearray size is >= bytearray size, return string\n",
    "* Create compressed_bytearray\n",
    "* pos = 0\n",
    "* For each char code in bytearray\n",
    "    * If char code == last_char_code\n",
    "        count++\n",
    "    * Else\n",
    "        * compressed_bytearray[pos] = last_char_code\n",
    "        * compressed_bytearray[pos + 1] = count\n",
    "        * pos += 2\n",
    "        * count = 1\n",
    "        * last_char_code = char code\n",
    "    * compressed_bytearray[pos] = last_char_code\n",
    "    * compressed_bytearray[pos + 1] = count\n",
    "* return compressed_bytearray\n",
 </s> add     "The algorithm is the same, except we will need to work with the bytearray's character codes instead of the characters as we did above when we implemented this solution with a list.\n", </s> remove     "* Space: O(m) where m is the size of the compressed bytearray"
 </s> add     "* Space: O(2m) where m is the size of the compressed list and the resulting string copied from the list" </s> remove     "## Problem: Compress a String Such that 'AAABCCDDDD' Becomes 'A3B1C2D4'.  Only Compress if it Saves Space.\n",
 </s> add     "## Problem: Compress a string such that 'AAABCCDDDD' becomes 'A3B1C2D4'\n", </s> remove     "    * Yes"
 </s> add     "    * Yes\n",
    "* Do you compress even if it doesn't save space?\n",
    "    * No"
    "Since Python strings are immutable, we'll use a list of characters to exercise string manipulation.  Note using a list vs a bytearray will will result in additional space to create the list and to convert the list to a string.\n",
      "## Algorithm: List\n",
      "\n",
      "![alt text](https://raw.githubusercontent.com/donnemartin/algorithms-data-structures/master/images/compress_string.jpg)\n",
      "\n",
    "Since Python strings are immutable, we'll use a list of characters to exercise string manipulation.  Note using a list vs a bytearray will will result in additional space to create the list and to convert the list to a string.\n",
      "\n",
      "* If string is empty return string\n",
      "* count = 0\n",
      "* size = 0\n",
      "* last_char = first char in string\n",
keep keep keep keep replace keep keep keep keep keep
 Cleaned up string compress notebook.  Refactored duplicate algorithm description. 
arrays-strings/compress.ipynb