1025. Convert Octal to Decimal

You are given an octal number (base 8) in the form of a string. Your task is to convert it into its decimal (base 10) representation and return it as an integer.

Example 1:

Input: 345

Output: 229

Explanation: 3×8² + 4×8¹ + 5×8⁰ = 192 + 32 + 5 = 229

Example 2:

Input: 170

Output: 120

Explanation: 1×8² + 7×8¹ + 0×8⁰ = 64 + 56 = 120

Now Your Turn!

Pick the correct output for the given input

Input: 77

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • The input is a valid non-negative octal number.
  • 1 <= length of Octal number <= 1000
  • The input will contain only digits from 0 to 7.
0
class Solution {
public:
int octalToDecimal(string N) {
// Your code goes here
}
};
Test Case

Input:

N