Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 365f8d3

Browse files
HackerEarth String Problems
1 parent 10a305a commit 365f8d3

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Given a string 'S' , u need to tell whether it is 'sumit's string or not'.
2+
#
3+
# A string is called 'Sumit's String' , if distance between adjacent character is 1.
4+
#
5+
# Consider that the alphabets are arranged in cyclic manner from 'a' to 'z'. distance between any character
6+
# 'x' and 'y' will be defined as minimum number of steps it takes 'x' to reach 'y'. Here, character 'x' can
7+
# start moving clockwise or anti-clockwise in order to reach at position where character 'y' is placed.
8+
#
9+
# Print 'YES' if it is Sumit's string else print 'NO', for each yest case.
10+
#
11+
# Input :
12+
#
13+
# test cases, t
14+
# string , s
15+
# Output:
16+
#
17+
# Desired O/p
18+
#
19+
# Constraints :
20+
#
21+
# string length<=250
22+
# string has only lower case letters
23+
#
24+
# SAMPLE INPUT
25+
# 3
26+
# aba
27+
# zza
28+
# bcd
29+
#
30+
# SAMPLE OUTPUT
31+
# YES
32+
# NO
33+
# YES
34+
35+
for _ in range(int(input())):
36+
string = input()
37+
sumit_string = True
38+
check = 'abcdefghijklmnopqrstuvwxyz'
39+
for i in range(len(string) - 1):
40+
check_first = check.find(string[i]) + 1
41+
check_second = check.find(string[i + 1]) + 1
42+
if abs(check_second - check_first) == 1 or abs(check_second - check_first) == 25:
43+
continue
44+
else:
45+
sumit_string = False
46+
break
47+
48+
if sumit_string:
49+
print('YES')
50+
else:
51+
print('NO')
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Given a string S. Your task is to remove all duplicates characters from the string S
2+
#
3+
# NOTE:
4+
# 1.) Order of characters in output string should be same as given in input string.
5+
# 2.) String S contains only lowercase characters ['a'-'z'].
6+
#
7+
# input:
8+
# Input contain a single string S.
9+
#
10+
# Output:
11+
# Print the string S with no any duplicate characters.
12+
#
13+
# Constraints:
14+
# Test Files 1 to 5:
15+
# 1<=|S|<=100
16+
# Test Files 6 to 10:
17+
# 1<=|S|<=100000
18+
#
19+
# Sample Output #1
20+
# hacker
21+
#
22+
# Sample Output #1
23+
# hacker
24+
#
25+
# Sample Input #2
26+
# hackerearth
27+
#
28+
# Sample Output #2
29+
# hackert
30+
#
31+
# Sample Input #3
32+
# programming
33+
#
34+
# Sample Output #3
35+
# progamin
36+
37+
string = list(input())
38+
result = []
39+
for i in range(len(string)):
40+
if string[i] not in result:
41+
result.append(string[i])
42+
43+
print(''.join(result))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Given a string, convert it into its number form .
2+
#
3+
# A or a -> 1
4+
# B or b -> 2
5+
# C or c -> 3
6+
# . . .
7+
# Z or z -> 26
8+
# space -> $
9+
# Input:
10+
#
11+
# test cases, t
12+
# string , s
13+
# Output:
14+
#
15+
# Desired O/p
16+
#
17+
# Constraints: string length <=200
18+
#
19+
# SAMPLE INPUT
20+
# 2
21+
# AMbuj verma
22+
# Aaaa bBBB
23+
#
24+
# SAMPLE OUTPUT
25+
# 1132211022518131ドル
26+
# 11112222ドル
27+
28+
for _ in range(int(input())):
29+
string = input()
30+
check = 'abcdefghijklmnopqrstuvwxyz'
31+
result = []
32+
for i in range(len(string)):
33+
if string[i].lower() != ' ':
34+
result.append(check.find(string[i].lower()) + 1)
35+
else:
36+
result.append('$')
37+
38+
print(''.join([str(i) for i in result]))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /