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 83572fe

Browse files
author
JainMaster
authored
Add files via upload
1 parent 31e2104 commit 83572fe

File tree

55 files changed

+4871
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4871
-0
lines changed

‎10.Strings/Check Palindrome.ipynb

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Check Palindrome\n",
8+
"Given a String s, check it its palindrome. Return true if string is palindrome, else return false.<br>\n",
9+
"Palindrome strings are those, where string s and its reverse is exactly same.<br>\n",
10+
"<br>\n",
11+
"Input Format :<br>\n",
12+
" String S<br>\n",
13+
" <br>\n",
14+
"Output Format :<br>\n",
15+
"\"true\" if S is palindrome, else \"false\"<br>\n",
16+
"<br>\n",
17+
"Constraints :<br>\n",
18+
"0 <= |S| <= 10^7<br>\n",
19+
"where |S| represents the length of string, S.<br>\n",
20+
"<br>\n",
21+
"Sample Input 1 :<br>\n",
22+
"abcdcba<br>\n",
23+
"Sample Output 1 :<br>\n",
24+
"true <br>\n",
25+
"Sample Input 1 :<br>\n",
26+
"abcd<br>\n",
27+
"Sample Output 1 :<br>\n",
28+
"false"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": null,
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"str=input()\n",
38+
"if str==str[::-1]:\n",
39+
" print(\"true\")\n",
40+
"else:\n",
41+
" print(\"false\")"
42+
]
43+
}
44+
],
45+
"metadata": {
46+
"kernelspec": {
47+
"display_name": "Python 3",
48+
"language": "python",
49+
"name": "python3"
50+
},
51+
"language_info": {
52+
"codemirror_mode": {
53+
"name": "ipython",
54+
"version": 3
55+
},
56+
"file_extension": ".py",
57+
"mimetype": "text/x-python",
58+
"name": "python",
59+
"nbconvert_exporter": "python",
60+
"pygments_lexer": "ipython3",
61+
"version": "3.8.6"
62+
}
63+
},
64+
"nbformat": 4,
65+
"nbformat_minor": 4
66+
}

‎10.Strings/Check Permutation.ipynb

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Check Permutation\n",
8+
"Given two strings, S and T, check if they are permutations of each other. Return true or false.<br>\n",
9+
"Permutation means - length of both the strings should same and should contain same set of characters. Order of characters doesn't matter.<br>\n",
10+
"Note : Input strings contain only lowercase english alphabets.<br>\n",
11+
"<br>\n",
12+
"<br>\n",
13+
"Input format :<br>\n",
14+
"Line 1 : String 1<br>\n",
15+
"Line 2 : String 2<br>\n",
16+
"<br>\n",
17+
"Output format :<br>\n",
18+
"'true' or 'false'<br>\n",
19+
"<br>\n",
20+
"Constraints :<br>\n",
21+
"0 <= |S| <= 10^7<br>\n",
22+
"0 <= |T| <= 10^7<br>\n",
23+
"where |S| represents the length of string, S.<br>\n",
24+
"<br>\n",
25+
"Sample Input 1 :<br>\n",
26+
"abcde<br>\n",
27+
"baedc<br>\n",
28+
"Sample Output 1 :<br>\n",
29+
"true<br>\n",
30+
"Sample Input 2 :<br>\n",
31+
"abc<br>\n",
32+
"cbd<br>\n",
33+
"Sample Output 2 :<br>\n",
34+
"false"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"s=input()\n",
44+
"d=input()\n",
45+
"if sorted(d)==sorted(s):\n",
46+
" print(\"true\")\n",
47+
"else:\n",
48+
" print(\"false\")"
49+
]
50+
}
51+
],
52+
"metadata": {
53+
"kernelspec": {
54+
"display_name": "Python 3",
55+
"language": "python",
56+
"name": "python3"
57+
},
58+
"language_info": {
59+
"codemirror_mode": {
60+
"name": "ipython",
61+
"version": 3
62+
},
63+
"file_extension": ".py",
64+
"mimetype": "text/x-python",
65+
"name": "python",
66+
"nbconvert_exporter": "python",
67+
"pygments_lexer": "ipython3",
68+
"version": "3.8.6"
69+
}
70+
},
71+
"nbformat": 4,
72+
"nbformat_minor": 4
73+
}

‎10.Strings/Compress the String.ipynb

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Compress the String\n",
8+
"Write a program to do basic string compression. For a character which is consecutively repeated more than once, replace consecutive duplicate occurrences with the count of repetitions.<br>\n",
9+
"<br>\n",
10+
"Exmple:<br>\n",
11+
"If a String has 'x' repeated 5 times, replace this \"xxxxx\" with \"x5\".<br>\n",
12+
"<br>\n",
13+
"The string is compressed only when the repeated character count is more than 1.<br>\n",
14+
"<br>\n",
15+
"Note :<br>\n",
16+
"Consecutive count of every character in the input string is less than equal to 9.<br>\n",
17+
"<br>\n",
18+
"<br>\n",
19+
"Input Format :<br>\n",
20+
"The first and the only line of input contains a string(no spaces in between).<br>\n",
21+
"<br>\n",
22+
"Output Format :<br>\n",
23+
"The only line of output print the compressed string.<br>\n",
24+
"<br>\n",
25+
"Note:<br>\n",
26+
"Return the compressed string and hence, no need to print.<br>\n",
27+
"<br>\n",
28+
"Constraints :<br>\n",
29+
"0 <= |S| <= 10^7<br>\n",
30+
"Where |S| represents the length of string, S.<br>\n",
31+
"<br>\n",
32+
"Time Limit: 1sec<br>\n",
33+
"Sample Input 1 :<br>\n",
34+
"aaabbccdsa<br>\n",
35+
"Sample Output 1 :<br>\n",
36+
"a3b2c2dsa<br>\n",
37+
"Sample Input 2 :<br>\n",
38+
"aaabbcddeeeee<br>\n",
39+
"Sample Output 2 :<br>\n",
40+
"a3b2cd2e5"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"def ab(a):\n",
50+
" i=0\n",
51+
" x=''\n",
52+
" while(i<len(a)):\n",
53+
" j=i+1\n",
54+
" c=1\n",
55+
" while j<len(a) and (a[i]==a[j]):\n",
56+
" j+=1\n",
57+
" c+=1\n",
58+
" if c==1:\n",
59+
" x+=a[i]\n",
60+
" else:\n",
61+
" x+=a[i]+str(c)\n",
62+
" i=j\n",
63+
" return x\n",
64+
"a=input()\n",
65+
"print(ab(a))"
66+
]
67+
}
68+
],
69+
"metadata": {
70+
"kernelspec": {
71+
"display_name": "Python 3",
72+
"language": "python",
73+
"name": "python3"
74+
},
75+
"language_info": {
76+
"codemirror_mode": {
77+
"name": "ipython",
78+
"version": 3
79+
},
80+
"file_extension": ".py",
81+
"mimetype": "text/x-python",
82+
"name": "python",
83+
"nbconvert_exporter": "python",
84+
"pygments_lexer": "ipython3",
85+
"version": "3.8.6"
86+
}
87+
},
88+
"nbformat": 4,
89+
"nbformat_minor": 4
90+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Highest Occurring Character\n",
8+
"Given a string, S, find and return the highest occurring character present in the given string.<br>\n",
9+
"If there are 2 characters in the input string with same frequency, return the character which comes first.<br>\n",
10+
"<br>\n",
11+
"Note : Assume all the characters in the given string are lowercase.<br>\n",
12+
"<br>\n",
13+
"Input format :<br>\n",
14+
"String S<br>\n",
15+
"<br>\n",
16+
"Output format :<br>\n",
17+
"Highest occurring character<br>\n",
18+
"<br>\n",
19+
"Constraints :<br>\n",
20+
"0 <= |S| <= 10^7<br>\n",
21+
"where |S| represents the length of string, S.<br>\n",
22+
"<br>\n",
23+
"Sample Input 1:<br>\n",
24+
"abdefgbabfba<br>\n",
25+
"Sample Output 1:<br>\n",
26+
"b<br>\n",
27+
"Sample Input 2:<br>\n",
28+
"xy<br>\n",
29+
"Sample Output 2:<br>\n",
30+
"x"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"myList=input()\n",
40+
"newlist_d=[]\n",
41+
"maxalpha=\"\"\n",
42+
"maxno=0\n",
43+
"\n",
44+
"#Give list of all distinct words\n",
45+
"for i in (myList):\n",
46+
" if i not in newlist_d:\n",
47+
" newlist_d.append(i)\n",
48+
"#now let count\n",
49+
"for ele in newlist_d:\n",
50+
" count = 0\n",
51+
" for l in range(len(myList)):\n",
52+
" if ele==myList[l]:\n",
53+
" count+=1\n",
54+
" if count>maxno:\n",
55+
" maxno=count\n",
56+
" maxalpha=ele\n",
57+
"print(maxalpha)"
58+
]
59+
}
60+
],
61+
"metadata": {
62+
"kernelspec": {
63+
"display_name": "Python 3",
64+
"language": "python",
65+
"name": "python3"
66+
},
67+
"language_info": {
68+
"codemirror_mode": {
69+
"name": "ipython",
70+
"version": 3
71+
},
72+
"file_extension": ".py",
73+
"mimetype": "text/x-python",
74+
"name": "python",
75+
"nbconvert_exporter": "python",
76+
"pygments_lexer": "ipython3",
77+
"version": "3.8.6"
78+
}
79+
},
80+
"nbformat": 4,
81+
"nbformat_minor": 4
82+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Remove Consecutive Duplicates\n",
8+
"Given a string, S, remove all the consecutive duplicates that are present in the given string. That means, if 'aaa' is present in the string then it should become 'a' in the output string.<br>\n",
9+
"<br>\n",
10+
"Input format :<br>\n",
11+
"String S<br>\n",
12+
"<br>\n",
13+
"Output format :<br>\n",
14+
"Modified string<br>\n",
15+
"<br>\n",
16+
"Constraints :<br>\n",
17+
"0 <= |S| <= 10^7<br>\n",
18+
"where |S| represents the length of string, S.<br>\n",
19+
"<br>\n",
20+
"Sample Input 1:<br>\n",
21+
"aabccbaa<br>\n",
22+
"Sample Output 1:<br>\n",
23+
"abcba<br>\n",
24+
"Sample Input 2:<br>\n",
25+
"xxyyzxx<br>\n",
26+
"Sample Output 2:<br>\n",
27+
"xyzx"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"s=input()\n",
37+
"s=s+\" \"\n",
38+
"for i in range(len(s)-1):\n",
39+
" if s[i]!=s[i+1]:\n",
40+
" print(s[i],end=\"\")"
41+
]
42+
}
43+
],
44+
"metadata": {
45+
"kernelspec": {
46+
"display_name": "Python 3",
47+
"language": "python",
48+
"name": "python3"
49+
},
50+
"language_info": {
51+
"codemirror_mode": {
52+
"name": "ipython",
53+
"version": 3
54+
},
55+
"file_extension": ".py",
56+
"mimetype": "text/x-python",
57+
"name": "python",
58+
"nbconvert_exporter": "python",
59+
"pygments_lexer": "ipython3",
60+
"version": "3.8.6"
61+
}
62+
},
63+
"nbformat": 4,
64+
"nbformat_minor": 4
65+
}

0 commit comments

Comments
(0)

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