Skip to content

Instantly share code, notes, and snippets.

@mogutou1214
mogutou1214 / gist:5675756
Last active December 17, 2015 21:38
Careercup1.5 - Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string conv2str(int num){
ostringstream ostr; //output string stream
ostr << num; //use the string stream just like cout,
return ostr.str();
}