Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

HackerRank Group(), Groups(), & Groupdict() solution in python

YASH PAL, 31 July 2024

In this Group(), Groups(), & Groupdict() problem, You are given a string S. Your task is to find the first occurrence of an alphanumeric character in S (read from left to right) that has consecutive repetitions.

HackerRank Group(), Groups(), & Groupdict() solution in python

Problem solution in Python 2 programming.

from __future__ import print_function
import re
r=re.search(r'([0-9a-zA-Z])1',raw_input())
print(r.group(1) if r else -1)

Problem solution in Python 3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
m = re.findall(r"([A-Za-z0-9])1+",input())
if m:
    print(m[0])
else:
    print(-1)

Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
s=raw_input()
m=re.search(r'([a-z0-9])1+',s)
if m is None:
    print -1
else:
    print m.group(0)[1]

Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
m = re.search(r'([a-zA-Z0-9])1', input().strip())
print(m.group(1) if m else -1)

coding problems solutions Python Solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes