Simple c++ solution with explanation || 0ms
Approach:\n\t1) First we will check for number, if(num == 0), then we return "0".\n\t2) We are using flag variable for identifying the number as positive or neg
**Approach:**\n\t1) First we will check for number, if(num == 0), then we return "0".\n\t2) We are using flag variable for identifying the number as positive or negative.\n\t3) we are converting the number into positive.\n\t4) Then we are iterating and each time we push the remainder into the string and number is decremented to num/7 until the number is zero.\n\t5) After looping we are reversing the string and checking for the negative number if flag==1 then it is negative so we are adding negative sign and beginning and then returning the string.\n```\nstring convertToBase7(int num) {\n        if(num==0) return "0";\n        string ret;\n        int flag=0;\n        if(num<0)\n            flag=1;\n        num = abs(num);\n        while(num != 0){\n            ret.push_back((num%7)+\'0\');\n            num/=7;\n        }\n        reverse(ret.begin(),ret.end());\n        if(flag==1){\n            ret.insert(ret.begin(),\'-\');\n        }\n        return ret;\n    }\n```\nIf you get some value from this, then show some love by upvoting it !!\nHappy Coding \uD83D\uDE0A\uD83D\uDE0A
['C', 'C++']