Skip to content

Latest commit

 

History

History

longestDigitsPrefix

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Check Out My YouTube Channel

Algorithm Challenge Available At CodeFights

Given a string, output its longest prefix which contains only digits.

Example

For inputString="123aa1", the output should be longestDigitsPrefix(inputString) = "123".

Hints

  • split()
  • includes()
  • push()
  • join()

Input/Output

  • [time limit] 4000ms (js)
  • [input] string inputString

Guaranteed constraints:

3 ≤ inputString.length ≤ 35.

  • [output] string