[Leet Code] Number of Different Integers in a String

Input: word = "a123bc34d8ef34"
Output: 3
Explanation: The three different integers are "123", "34", and "8". Notice that "34" is only counted once.
Input: word = "leet1234code234"
Output: 2
Input: word = "a1b01c001"
Output: 1
Explanation: The three integers "1", "01", and "001" all represent the same integer because
the leading zeros are ignored when comparing their decimal values.
class Solution(object):
def numDifferentIntegers(self, word):
:type word: str
:rtype: int
answers = []
lengthOfWord = len(word)
i = 0
while i < lengthOfWord:
if word[i].isnumeric():
number = ""
while i < lengthOfWord and word[i].isnumeric():
number += word[i]
i += 1
i += 1
return len(set(answers))




Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

from Twitter https://twitter.com/livrpoollocks

Windows Command Line — Fu: Part 3

The What, Why and How of Mobile App Maintenance

Three Tier Routing based Generic Microservices architecture with Serverless and Serverbased…

How To Create Your Own CLI — With Golang

Middleware in ASP.NET Core

What You Should Know About Concurrency — Part III — Implementation with Ada, Java, C#

How to use GIT with Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew Boyd

Matthew Boyd

Learning, and posting my findings!

More from Medium

Course Schedule II Solution | LeetCode-210: Medium | JavaScript Implementation

LeetCode: Palindrome Number

Leetcode — Isomorphic Strings — Easy

Sliding Window #1: Finding the maximum sum of k consecutive elements in an array