Skip to content

Commit 515b5de

Browse files
authored
First Commit
1 parent 8e8b2ac commit 515b5de

File tree

85 files changed

+7767
-2
lines changed

Some content is hidden

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

85 files changed

+7767
-2
lines changed

1 Flow-Chart

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

10 Strings/Check Palindrome.ipynb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"s=input()\n",
10+
"p=s[::-1]\n",
11+
"if(s==p):\n",
12+
" print(\"true\")\n",
13+
"else:\n",
14+
" print(\"false\")"
15+
]
16+
}
17+
],
18+
"metadata": {
19+
"kernelspec": {
20+
"display_name": "Python 3",
21+
"language": "python",
22+
"name": "python3"
23+
},
24+
"language_info": {
25+
"codemirror_mode": {
26+
"name": "ipython",
27+
"version": 3
28+
},
29+
"file_extension": ".py",
30+
"mimetype": "text/x-python",
31+
"name": "python",
32+
"nbconvert_exporter": "python",
33+
"pygments_lexer": "ipython3",
34+
"version": "3.7.6"
35+
}
36+
},
37+
"nbformat": 4,
38+
"nbformat_minor": 4
39+
}

10 Strings/Check Permutation.ipynb

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"Check Permutation\n",
10+
"--------------------\n",
11+
"Given two strings, S and T, check if they are permutations of each other. Return true or false.\n",
12+
"Permutation means - length of both the strings should same and should contain same set of characters. Order of characters doesn't matter.\n",
13+
"Note : Input strings contain only lowercase english alphabets.\n",
14+
"\n",
15+
"\n",
16+
"Input format :\n",
17+
"Line 1 : String 1\n",
18+
"Line 2 : String 2\n",
19+
"Output format :\n",
20+
"'true' or 'false'\n",
21+
"Constraints :\n",
22+
"0 <= |S| <= 10^7\n",
23+
"0 <= |T| <= 10^7\n",
24+
"where |S| represents the length of string, S.\n",
25+
"Sample Input 1 :\n",
26+
"abcde\n",
27+
"baedc\n",
28+
"Sample Output 1 :\n",
29+
"true"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": 1,
35+
"metadata": {},
36+
"outputs": [
37+
{
38+
"name": "stdout",
39+
"output_type": "stream",
40+
"text": [
41+
"abcde\n",
42+
"baedc\n",
43+
"true\n"
44+
]
45+
}
46+
],
47+
"source": [
48+
"def arePermutation(str1, str2):\n",
49+
" \n",
50+
" n1 = len(str1) \n",
51+
" n2 = len(str2)\n",
52+
" if (n1 != n2):\n",
53+
" return False\n",
54+
" \n",
55+
" # Sort both strings \n",
56+
" a = sorted(str1) \n",
57+
" str1 = \"\".join(a) \n",
58+
" b = sorted(str2) \n",
59+
" str2 = \"\".join(b) \n",
60+
" \n",
61+
" # Compare sorted strings \n",
62+
" for i in range(0, n1, 1): \n",
63+
" if (str1[i] != str2[i]): \n",
64+
" return False\n",
65+
" \n",
66+
" return True\n",
67+
" \n",
68+
"str1 = input()\n",
69+
"str2 = input()\n",
70+
"if (arePermutation(str1, str2)):\n",
71+
" print(\"true\") \n",
72+
"else: \n",
73+
" print(\"false\") "
74+
]
75+
}
76+
],
77+
"metadata": {
78+
"kernelspec": {
79+
"display_name": "Python 3",
80+
"language": "python",
81+
"name": "python3"
82+
},
83+
"language_info": {
84+
"codemirror_mode": {
85+
"name": "ipython",
86+
"version": 3
87+
},
88+
"file_extension": ".py",
89+
"mimetype": "text/x-python",
90+
"name": "python",
91+
"nbconvert_exporter": "python",
92+
"pygments_lexer": "ipython3",
93+
"version": "3.7.6"
94+
}
95+
},
96+
"nbformat": 4,
97+
"nbformat_minor": 4
98+
}

10 Strings/Compress the String.ipynb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"aaabbccdsa\n",
13+
"a3b2c2dsa\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"def ab(a):\n",
19+
" i=0\n",
20+
" x=''\n",
21+
" while(i<len(a)):\n",
22+
" j=i+1\n",
23+
" c=1\n",
24+
" while j<len(a) and (a[i]==a[j]):\n",
25+
" j+=1\n",
26+
" c+=1\n",
27+
" if c==1:\n",
28+
" x+=a[i]\n",
29+
" else:\n",
30+
" x+=a[i]+str(c)\n",
31+
" i=j\n",
32+
" return x\n",
33+
"a=input()\n",
34+
"print(ab(a))"
35+
]
36+
}
37+
],
38+
"metadata": {
39+
"kernelspec": {
40+
"display_name": "Python 3",
41+
"language": "python",
42+
"name": "python3"
43+
},
44+
"language_info": {
45+
"codemirror_mode": {
46+
"name": "ipython",
47+
"version": 3
48+
},
49+
"file_extension": ".py",
50+
"mimetype": "text/x-python",
51+
"name": "python",
52+
"nbconvert_exporter": "python",
53+
"pygments_lexer": "ipython3",
54+
"version": "3.7.6"
55+
}
56+
},
57+
"nbformat": 4,
58+
"nbformat_minor": 4
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"abdefgbabfba\n",
13+
"b\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"def get_max_occuring_char(str1):\n",
19+
" ASCII_SIZE = 256\n",
20+
" ctr = [0] * ASCII_SIZE\n",
21+
" max = -1\n",
22+
" ch = ''\n",
23+
" for i in str1:\n",
24+
" ctr[ord(i)]+=1;\n",
25+
" \n",
26+
" for i in str1:\n",
27+
" if max < ctr[ord(i)]:\n",
28+
" max = ctr[ord(i)]\n",
29+
" ch = i\n",
30+
" return ch\n",
31+
"\n",
32+
"str1=input()\n",
33+
"print(get_max_occuring_char(str1))"
34+
]
35+
}
36+
],
37+
"metadata": {
38+
"kernelspec": {
39+
"display_name": "Python 3",
40+
"language": "python",
41+
"name": "python3"
42+
},
43+
"language_info": {
44+
"codemirror_mode": {
45+
"name": "ipython",
46+
"version": 3
47+
},
48+
"file_extension": ".py",
49+
"mimetype": "text/x-python",
50+
"name": "python",
51+
"nbconvert_exporter": "python",
52+
"pygments_lexer": "ipython3",
53+
"version": "3.7.6"
54+
}
55+
},
56+
"nbformat": 4,
57+
"nbformat_minor": 4
58+
}

10 Strings/Remove Character.ipynb

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"wellcome to codingninjas\n",
13+
"o\n",
14+
"wellcme t cdingninjas\n"
15+
]
16+
}
17+
],
18+
"source": [
19+
"s=input()\n",
20+
"ch=input()\n",
21+
"print(s.replace(ch, ''))"
22+
]
23+
}
24+
],
25+
"metadata": {
26+
"kernelspec": {
27+
"display_name": "Python 3",
28+
"language": "python",
29+
"name": "python3"
30+
},
31+
"language_info": {
32+
"codemirror_mode": {
33+
"name": "ipython",
34+
"version": 3
35+
},
36+
"file_extension": ".py",
37+
"mimetype": "text/x-python",
38+
"name": "python",
39+
"nbconvert_exporter": "python",
40+
"pygments_lexer": "ipython3",
41+
"version": "3.7.6"
42+
}
43+
},
44+
"nbformat": 4,
45+
"nbformat_minor": 4
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"aabccbaa\n",
13+
"abcba\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"import itertools\n",
19+
"def remove_consecutive_duplicates(s1):\n",
20+
" return (''.join(i for i, _ in itertools.groupby(s1)))\n",
21+
"\n",
22+
"s1= input()\n",
23+
"print(remove_consecutive_duplicates(s1))"
24+
]
25+
}
26+
],
27+
"metadata": {
28+
"kernelspec": {
29+
"display_name": "Python 3",
30+
"language": "python",
31+
"name": "python3"
32+
},
33+
"language_info": {
34+
"codemirror_mode": {
35+
"name": "ipython",
36+
"version": 3
37+
},
38+
"file_extension": ".py",
39+
"mimetype": "text/x-python",
40+
"name": "python",
41+
"nbconvert_exporter": "python",
42+
"pygments_lexer": "ipython3",
43+
"version": "3.7.6"
44+
}
45+
},
46+
"nbformat": 4,
47+
"nbformat_minor": 4
48+
}

0 commit comments

Comments
 (0)