Skip to content
Optimal Lab

Practice · 6 problems

Strings

0 of 6 solved on this device

  1. 098Longest Common PrefixWrite a function to find the longest common prefix string among an array of strings. If there is no common prefix, return the empty string.Easy
  2. 099Roman to IntegerGiven a roman numeral string, convert it to an integer. Symbols: I=1, V=5, X=10, L=50, C=100, D=500, M=1000. A smaller symbol placed before a larger one means subtraction (IV = 4, IX = 9, CM = 900).Easy
  3. 100String to Integer (atoi)Implement atoi: skip leading whitespace, read an optional '+' or '-' sign, then read as many digits as possible and stop at the first non-digit. Clamp the result to the 32-bit signed range [-2^31, 2^31 - 1]. Return 0 if no digits.Medium
  4. 130Reverse Words in a StringGiven a string `s`, reverse the order of the words. Words are separated by one or more spaces. The result must have single spaces between words and no leading or trailing space.Medium
  5. 131Zigzag ConversionWrite the string `s` in a zigzag pattern across `numRows` rows, then read it off row by row and return the resulting string.Medium
  6. 132Multiply StringsGiven two non-negative integers represented as strings, return their product, also as a string. You may not convert them to a built-in big-integer type directly.Medium