| A step-by-step breakdown of everyones first system design interview question, Design Bit.ly. Evan, a former Meta Staff Engineer and current co-founder of Hello Interview, walks through the problem from the perspective of an interviewer.  








<?php
class Base62 {
private static $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
private static $base = 62;
// Encode a decimal number to Base62
public static function encode($num) {
if ($num == 0) return self::$charset[0];
$result = '';
while ($num > 0) {
$result = self::$charset[$num % self::$base] . $result;
$num = intdiv($num, self::$base);
}
return $result;
}
// Decode a Base62 string to decimal
public static function decode($str) {
$length = strlen($str);
$num = 0;
for ($i = 0; $i < $length; $i++) {
$pos = strpos(self::$charset, $str[$i]);
$num = $num * self::$base + $pos;
}
return $num;
}
}
// Example usage
$original = 123456789;
$encoded = Base62::encode($original);
$decoded = Base62::decode($encoded);
echo "Original: $original\n";
echo "Encoded : $encoded\n";
echo "Decoded : $decoded\n";

Candidate expected to use https://excalidraw.com/ Tags: Meta Interview System Design Interview  |