Find the length of longest substring composed of same digit, within a string of digits: (was asked to complete within 10 mins) E.g. 01241XXXXX901111 Output: 4 Explanation: "1111" is the longest substring
Find the length of longest substring composed of same digit within a string of digits.
Iterate through the string and keep track of the current digit and its count
Update the maximum count whenever a ne...read more
Code in CPP:
#include <bits/stdc++.h>
using namespace std;
int main()
{
//input
string s="01241XXXXX901111";
//storing integer values in the vector
vector<int>ans;
for(int i=0;i<s.size();i++)
{
if(s[i]-...read more
#python
arr=input()
c=1
char=arr[0]
ans=1
h={}
if len(arr)==0:
print(0)
else:
for i in range(1,len(arr)):
if arr[i].isdigit():
if char==arr[i]:
c+=1
ans=max(ans,c)
else:
c=1
char=arr[i]
print(ans)
#input 0124...read more
def find_longest_same_digit_substring(s):
if not s:
return 0
max_length = 1 # Initialize with 1 to account for the single character substring
current_length = 1
current_digit = s[0]
for i in range(1, ...read more
Top Zenoti Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Zenoti Software Engineer
Reviews
Interviews
Salaries
Users/Month