Given a string s, extract all the integers from s. 
Example 1:
Input:
s = "1: Prakhar Agrawal, 2: Manish Kumar Rai, 
     3: Rishabh Gupta56"
Output: 1 2 3 56
Explanation: 
1, 2, 3, 56 are the integers present in s.
Example 2:
Input:
s = "geeksforgeeks"
Output: No Integers
Explanation: 
No integers present in the string.
 
Your Task:
You don't need to read input or print anything. Complete the function extractIntegerWords() which takes string s as input and returns a list of integers. If an empty list is returned the output is printed as "No Integers".
 
Expected Time Complexity: O(|s|).
Expected Auxiliary Space: O(|s|).
 
Constraints:
1<=|s|<=10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Amortized analysis

Starter code: #User function Template for python3

class Solution:

    def extractIntegerWords(self, s):
        # code here

Solutions:
class Solution:

	def extractIntegerWords(self, s):
		res = []
		s1 = ''
		for e in s:
			if e.isnumeric():
				s1 = s1 + e
			else:
				s1 = s1 + ','
		s2 = s1.split(',')
		for e in s2:
			if e != '':
				res.append(e)
		return res


class Solution:

	def extractIntegerWords(self, s):
		result = ''
		for i in s:
			if i.isdigit():
				result += i
			else:
				result += ' '
		num_list = result.split()
		return num_list


class Solution:

	def extractIntegerWords(self, s):
		string = ''
		for i in s:
			if i.isnumeric():
				string += i
			else:
				string += ' '
		final = string.split()
		return final


import re

class Solution:

	def extractIntegerWords(self, s):
		res = re.findall('\\d+', s)
		return res


class Solution:

	def extractIntegerWords(self, s):
		result = []
		str_numero = ''
		for x in list(str(s)):
			if x in '0123456789':
				str_numero += x
			else:
				if not str_numero == '':
					result.append(str_numero)
				str_numero = ''
		if not str_numero == '':
			result.append(str_numero)
		return result


import re

class Solution:

	def extractIntegerWords(self, s):
		digits = re.findall('\\d+', s)
		if digits:
			return digits
		else:
			return 0


import re

class Solution:

	def extractIntegerWords(self, s):
		n = re.compile('[0-9]+')
		k = n.findall(s)
		return k


class Solution:

	def extractIntegerWords(self, s):
		s = s.split()
		a = ''
		for i in s:
			a += ' '
			for j in i:
				if j.isdigit():
					a += j
				else:
					a += ' '
		j = a.split()
		return j


class Solution:

	def extractIntegerWords(self, s):
		l = ''
		for i in s:
			if i.isdigit():
				l += i
			else:
				l += ' '
		numlist = l.split()
		return numlist


import re

class Solution:

	def extractIntegerWords(self, s):
		result = ''
		for char in s:
			if char.isdigit():
				result += char
			else:
				result += ' '
		num_list = result.split()
		return num_list


class Solution:

	def extractIntegerWords(self, s):
		p = '1234567890'
		d = ':;?=,>-_<abc@#%^&*)($!defghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
		j = ''
		k = []
		for i in range(len(s)):
			if s[i] in p and s[i] != ' ':
				j = j + s[i]
				if i == len(s) - 1:
					k.append(j)
			if (s[i] in d or s[i] == ' ') and s[i - 1] in p:
				k.append(j)
				j = ''
		if len(k) > 0:
			if k[0] == '':
				k.pop(0)
			return k
		else:
			return 0


class Solution:

	def extractIntegerWords(self, s):
		temp = ''
		for i in s:
			if i.isdigit():
				temp += i
			else:
				temp += ' '
		return temp.split()


class Solution:

	def extractIntegerWords(self, s):
		r = ''
		for i in s:
			if i.isdigit():
				r += i
			else:
				r += ' '
		ans = r.split()
		return ans


import re

class Solution:

	def extractIntegerWords(self, s):
		ok = re.findall('\\d+', s)
		return ok


class Solution:

	def extractIntegerWords(self, s):
		import re
		l = re.findall('[0-9]+', s)
		return l


class Solution:

	def extractIntegerWords(self, s):
		import re
		l = re.findall('[0-9]+', s)
		if len(l) != 0:
			return l
		else:
			return l


class Solution:

	def extractIntegerWords(self, s):
		import re
		l = re.findall('[0-9]+', s)
		a = 'No Integers'
		if len(l) != 0:
			return l
		else:
			return l


import re

class Solution:

	def extractIntegerWords(self, s):
		a = ''
		for i in s:
			if i.isdigit():
				a += i
			else:
				a += ' '
		n = a.split()
		return n


class Solution:

	def extractIntegerWords(self, s):
		ans = []
		x = 0
		tmp = ''
		for i in range(len(s)):
			if s[i] < '0' or s[i] > '9':
				continue
			tmp += s[i]
			if i + 1 < len(s) and '0' <= s[i + 1] and (s[i + 1] <= '9'):
				continue
			ans.append(tmp)
			tmp = ''
			x = 0
		return ans


import re

class Solution:

	def extractIntegerWords(self, s):
		s_nums = re.findall('\\d+', s)
		return s_nums


import re

class Solution:

	def extractIntegerWords(self, s):
		result = []
		result = re.findall('\\d+', s)
		return result


class Solution:

	def extractIntegerWords(self, s):
		stri = list(s)
		stri.append('fghh')
		s = ''.join(stri)
		intlist = []
		current = []
		for char in s:
			if char.isdigit():
				current.append(char)
			elif current:
				join = ''.join(current)
				intlist.append(join)
				current = []
		return intlist


class Solution:

	def extractIntegerWords(self, s):
		s = s + '/'
		ans = []
		temp = ''
		i = 0
		j = 0
		while i < len(s):
			if s[i] in '1234567890':
				j = i
				temp = ''
				while j < len(s):
					if s[j] in '1234567890':
						temp = temp + s[j]
						j = j + 1
					else:
						ans.append(temp)
						break
				i = j
			i = i + 1
		return ans


class Solution:

	def extractIntegerWords(self, s):
		l = []
		i = ''
		for a in s:
			if a.isdigit():
				i = i + a
			elif i != '':
				l.append(i)
				i = ''
		if i != '':
			l.append(i)
		return l


class Solution:

	def extractIntegerWords(self, a):
		a += 'a'
		b = []
		i = 0
		while i != len(a):
			if a[i].isdigit():
				if not a[i + 1].isdigit():
					b.append(a[i])
				else:
					c = ''
					while a[i].isdigit():
						c += a[i]
						i += 1
					b.append(c)
			i += 1
		return b


import re

class Solution:

	def extractIntegerWords(self, s):
		i = re.findall('\\d+', s)
		return i


class Solution:

	def extractIntegerWords(self, s):
		temp = ''
		res = []
		for i in s:
			if i.isdigit():
				temp = temp + i
			elif temp != '':
				res.append(temp)
				temp = ''
		if temp != '':
			res.append(temp)
		return res


class Solution:

	def extractIntegerWords(self, s, newst=''):
		result = ''
		for char in s:
			if char.isdigit():
				result += char
			else:
				result += ' '
		num_list = result.split()
		return num_list


class Solution:

	def extractIntegerWords(self, s):
		ls = ''
		for i in s:
			if i.isdigit():
				ls += i
			else:
				ls += ' '
		nl = ls.split()
		return nl


class Solution:

	def extractIntegerWords(self, s):
		integers = list()
		num = ''
		for i in s:
			if i.isdigit():
				num += i
			else:
				num += ' '
		return num.split()


class Solution:

	def extractIntegerWords(self, s):
		num = []
		temp = ''
		s_splited = s.split()
		for each in s_splited:
			for i in range(len(each)):
				if each[i].isdigit():
					temp += each[i]
				else:
					temp += ' '
			if len(temp) > 0:
				temp_splitted = temp.split()
				num.extend(temp_splitted)
				temp = ''
		if len(num) > 0:
			return num


class Solution:

	def extractIntegerWords(self, s):
		ans = []
		str = ''
		n = len(s)
		i = 0
		while i < n:
			if s[i].isdigit():
				while i < n and s[i].isdigit():
					str += s[i]
					i += 1
				ans.append(str)
				str = ''
			i += 1
		return ans


class Solution:

	def extractIntegerWords(self, s):
		temp = ''
		out = []
		for i in range(len(s)):
			if s[i].isdigit():
				temp += s[i]
				if i + 1 == len(s) or not s[i + 1].isdigit():
					out.append(temp)
					temp = ''
		return out


class Solution:

	def extractIntegerWords(self, s):
		nums = []
		(i, j) = (0, 0)
		while j < len(s):
			if s[j].isnumeric():
				j += 1
			else:
				if i < j:
					num_str = s[i:j]
					if num_str.startswith('0') and len(num_str) > 1:
						nums.append(num_str)
					else:
						nums.append(str(int(num_str)))
				i = j + 1
				j = i
		if i < j:
			num_str = s[i:j]
			if num_str.startswith('0') and len(num_str) > 1:
				nums.append(num_str)
			else:
				nums.append(str(int(num_str)))
		if not nums:
			return False
		else:
			return nums


class Solution:

	def extractIntegerWords(self, s):
		import re
		temp = re.findall('\\d+', s)
		return temp


class Solution:

	def extractIntegerWords(self, s):
		ints = []
		l = len(s)
		i = 0
		while i < l:
			v = s[i]
			if v.isnumeric() != True:
				i += 1
			else:
				temp_s = ''
				while i < l and s[i].isnumeric() == True:
					temp_s += s[i]
					i += 1
				ints.append(temp_s)
		return ints


class Solution:

	def extractIntegerWords(self, s):
		sq = '0123456789'
		a = []
		start = -1
		end = -1
		for index in range(len(s)):
			if s[index] in sq and start == -1 and (end == -1):
				start = index
				end = index
			elif s[index] in sq:
				end = index
			elif start != -1 and end != -1:
				a.append(s[start:end + 1])
				start = -1
				end = -1
		a.append(s[start:end + 1]) if start != -1 and end != -1 else None
		return a


import re

class Solution:

	def extractIntegerWords(self, s):
		temp = ''
		for i in range(len(s)):
			if s[i].isnumeric():
				temp += s[i]
			else:
				temp += ' '
		lst = temp.split()
		return lst


import re

class Solution:

	def extractIntegerWords(self, s):
		lst = []
		lst = re.findall('\\d+', s)
		return lst


class Solution:

	def extractIntegerWords(self, s):
		numbers = ''
		list_n = []
		for c in s:
			if c.isdigit():
				numbers += c
			elif c == '0':
				if len(numbers) == 0:
					numbers += c
				elif numbers == '0':
					continue
				else:
					list_n.append(numbers)
					numbers = ''
			elif len(numbers) != 0:
				list_n.append(numbers)
				numbers = ''
		if len(numbers) != 0:
			list_n.append(numbers)
		return list_n


import re

class Solution:

	def extractIntegerWords(self, s):
		pattern = '\\d+'
		l = re.findall(pattern, s)
		return l


class Solution:

	def extractIntegerWords(self, s):
		s1 = ''
		for i in s:
			if i.isdigit():
				s1 += i
			else:
				s1 += ' '
		num = s1.split()
		return num


class Solution:

	def extractIntegerWords(self, s):
		k = 0
		for i in s:
			if i.isnumeric():
				k = 1
				break
		if k != 0:
			fast = 1
			slow = 0
			a = str()
			ans = []
			while slow != len(s):
				if s[slow].isnumeric():
					a += s[slow]
					if slow == len(s) - 1:
						ans.append(a)
						a = ''
						break
					elif s[fast].isnumeric() == False:
						ans.append(a)
						a = ''
				fast += 1
				slow += 1
			if ans[-1] == ' ':
				ans = ans[:-1]
			return ans


class Solution:

	def extractIntegerWords(self, s):
		str_num = ''
		list_num = []
		for i in s:
			if i.isnumeric():
				str_num += i
			elif len(str_num) != 0:
				list_num.append(str_num)
				str_num = ''
		if len(str_num) != 0:
			list_num.append(str_num)
		return list_num


class Solution:

	def extractIntegerWords(self, s):
		l = ''
		for i in s:
			if i.isdigit() == True:
				l = l + i
			else:
				l = l + ' '
		a = l.split()
		return a


class Solution:

	def extractIntegerWords(self, s):
		S = ''
		for i in s:
			if i.isnumeric():
				S += i
			else:
				S += ' '
		S = S.split()
		return S


class Solution:

	def extractIntegerWords(self, s):
		a = ''
		for i in s:
			if i.isdigit():
				a += i
			else:
				a += ' '
		x = a.split()
		print
		return x


class Solution:

	def extractIntegerWords(self, s):
		p = []
		m = ''
		l = s.split()
		for i in l:
			for j in range(len(i)):
				if i[j].isdigit():
					m += i[j]
				else:
					m += ' '
			t = m.split()
			p.extend(t)
			m = ''
		return p