-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_basic_provlem_2nd_part.txt
More file actions
418 lines (208 loc) · 12.5 KB
/
python_basic_provlem_2nd_part.txt
File metadata and controls
418 lines (208 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
###### 100 Basic Python Programming Problems
###### These focus on fundamental concepts like variables, loops, conditionals, functions, and basic data structures.
######
###### 1\. Print "Hello, World!" to the console.
###### 2\. Add two numbers input by the user.
###### 3\. Check if a number is even or odd.
###### 4\. Calculate the square of a number.
###### 5\. Find the maximum of three numbers.
###### 6\. Check if a year is a leap year.
###### 7\. Calculate the factorial of a number.
###### 8\. Reverse a string.
###### 9\. Count the number of vowels in a string.
###### 10\. Check if a string is a palindrome.
###### 11\. Find the sum of all numbers from 1 to 100.
###### 12\. Print the first 10 Fibonacci numbers.
###### 13\. Convert Celsius to Fahrenheit.
###### 14\. Calculate the area of a circle given its radius.
###### 15\. Swap two variables without using a temporary variable.
###### 16\. Find the largest element in a list.
###### 17\. Count the occurrences of an element in a list.
###### 18\. Remove duplicates from a list.
###### 19\. Sort a list in ascending order.
###### 20\. Check if a number is prime.
###### 21\. Generate a multiplication table for a given number.
###### 22\. Find the GCD of two numbers.
###### 23\. Find the LCM of two numbers.
###### 24\. Convert a decimal number to binary.
###### 25\. Convert a binary number to decimal.
###### 26\. Check if a number is positive, negative, or zero.
###### 27\. Calculate the sum of digits in a number.
###### 28\. Find the length of a string without using len().
###### 29\. Replace all spaces in a string with underscores.
###### 30\. Count the number of words in a sentence.
###### 31\. Check if two strings are anagrams.
###### 32\. Find the ASCII value of a character.
###### 33\. Convert a string to uppercase.
###### 34\. Convert a string to lowercase.
###### 35\. Find the average of a list of numbers.
###### 36\. Check if a list is empty.
###### 37\. Merge two lists into one.
###### 38\. Find the second largest number in a list.
###### 39\. Print all even numbers between 1 and 50.
###### 40\. Print all odd numbers between 1 and 50.
###### 41\. Calculate the power of a number (e.g., x raised to n).
###### 42\. Check if a number is divisible by another number.
###### 43\. Find the sum of elements in a list.
###### 44\. Find the product of elements in a list.
###### 45\. Generate a list of squares of numbers from 1 to 10.
###### 46\. Check if a string contains only digits.
###### 47\. Check if a string contains only letters.
###### 48\. Remove all vowels from a string.
###### 49\. Find the length of the longest word in a sentence.
###### 50\. Count the number of digits in a number.
###### 51\. Print a pattern of stars in a triangle shape (5 rows).
###### 52\. Print a pattern of numbers (e.g., 1, 12, 123, etc.).
###### 53\. Find the minimum element in a list.
###### 54\. Check if a number is a perfect square.
###### 55\. Calculate the area of a rectangle.
###### 56\. Calculate the perimeter of a rectangle.
###### 57\. Find the roots of a quadratic equation.
###### 58\. Convert kilometers to miles.
###### 59\. Check if a number is a palindrome.
###### 60\. Generate a random number between 1 and 100.
###### 61\. Find the sum of even numbers in a list.
###### 62\. Find the sum of odd numbers in a list.
###### 63\. Reverse a list without using built-in functions.
###### 64\. Check if a list is sorted in ascending order.
###### 65\. Find the index of an element in a list.
###### 66\. Remove an element from a list by value.
###### 67\. Count the number of uppercase letters in a string.
###### 68\. Count the number of lowercase letters in a string.
###### 69\. Find the first non-repeating character in a string.
###### 70\. Calculate the sum of squares of numbers from 1 to n.
###### 71\. Check if a number is a perfect number.
###### 72\. Find the median of a list of numbers.
###### 73\. Convert a string to title case.
###### 74\. Check if a string starts with a specific prefix.
###### 75\. Check if a string ends with a specific suffix.
###### 76\. Find the longest common prefix in a list of strings.
###### 77\. Count the frequency of each character in a string.
###### 78\. Replace the first occurrence of a character in a string.
###### 79\. Check if a number is a Fibonacci number.
###### 80\. Calculate the sum of all prime numbers up to n.
###### 81\. Find the number of days between two dates.
###### 82\. Check if a string is a valid email address (basic check).
###### 83\. Find the area of a triangle given base and height.
###### 84\. Convert a number to its word representation (e.g., 123 to "one hundred twenty-three").
###### 85\. Check if a number is an Armstrong number.
###### 86\. Find the sum of all multiples of 3 or 5 below 100.
###### 87\. Generate a list of prime numbers up to 100.
###### 88\. Check if two lists have any common elements.
###### 89\. Find the intersection of two lists.
###### 90\. Find the union of two lists.
###### 91\. Rotate a list to the left by k positions.
###### 92\. Rotate a list to the right by k positions.
###### 93\. Find the number of occurrences of a substring in a string.
###### 94\. Check if a string contains only unique characters.
###### 95\. Find the sum of elements in a range (e.g., 10 to 20).
###### 96\. Calculate the volume of a cube.
###### 97\. Calculate the volume of a cylinder.
###### 98\. Check if a number is a power of 2.
###### 99\. Find the difference between two lists.
###### 100\. Print a pattern of stars in a square shape (5x5).
######
###### \### 100 Intermediate Python Programming Problems
###### These problems build on the basics and introduce more advanced concepts like recursion, data structures, algorithms, and file handling.
######
###### 1\. Implement a function to find the nth Fibonacci number using recursion.
###### 2\. Write a program to solve the Tower of Hanoi problem for n disks.
###### 3\. Implement a binary search algorithm for a sorted list.
###### 4\. Sort a list using the bubble sort algorithm.
###### 5\. Sort a list using the selection sort algorithm.
###### 6\. Sort a list using the insertion sort algorithm.
###### 7\. Merge two sorted lists into one sorted list.
###### 8\. Implement a function to check if a string is a valid palindrome (ignoring spaces and case).
###### 9\. Find all permutations of a string.
###### 10\. Find all combinations of a string.
###### 11\. Implement a stack using a list.
###### 12\. Implement a queue using a list.
###### 13\. Implement a deque (double-ended queue).
###### 14\. Reverse a linked list (implement a basic linked list first).
###### 15\. Find the middle element of a linked list.
###### 16\. Detect a cycle in a linked list.
###### 17\. Implement a binary tree and perform an in-order traversal.
###### 18\. Perform a pre-order traversal of a binary tree.
###### 19\. Perform a post-order traversal of a binary tree.
###### 20\. Find the height of a binary tree.
###### 21\. Check if a binary tree is balanced.
###### 22\. Find the lowest common ancestor in a binary tree.
###### 23\. Implement a function to check if two binary trees are identical.
###### 24\. Convert a sorted list to a balanced binary search tree.
###### 25\. Find the kth smallest element in a binary search tree.
###### 26\. Implement a trie data structure for prefix-based search.
###### 27\. Find the longest substring without repeating characters.
###### 28\. Find the longest palindromic substring in a string.
###### 29\. Implement a function to perform matrix multiplication.
###### 30\. Rotate a matrix by 90 degrees.
###### 31\. Print a matrix in spiral order.
###### 32\. Find the transpose of a matrix.
###### 33\. Implement a function to solve the N-Queens problem.
###### 34\. Generate all possible subsets of a set.
###### 35\. Find the sum of all subsets of a set.
###### 36\. Implement a function to solve a Sudoku puzzle.
###### 37\. Find the shortest path in a maze using backtracking.
###### 38\. Implement a function to calculate the edit distance between two strings.
###### 39\. Find the longest common subsequence of two strings.
###### 40\. Find the longest increasing subsequence in a list.
###### 41\. Implement a function to perform a depth-first search on a graph.
###### 42\. Implement a function to perform a breadth-first search on a graph.
###### 43\. Find the shortest path in an unweighted graph.
###### 44\. Detect a cycle in a directed graph.
###### 45\. Implement Dijkstra’s algorithm for shortest paths.
###### 46\. Implement a function to find the minimum spanning tree using Kruskal’s algorithm.
###### 47\. Implement a function to find the minimum spanning tree using Prim’s algorithm.
###### 48\. Find the strongly connected components in a graph.
###### 49\. Implement a function to perform topological sorting of a graph.
###### 50\. Find all connected components in an undirected graph.
###### 51\. Implement a function to compress a string (e.g., "aabbbcc" to "a2b3c2").
###### 52\. Decompress a compressed string (e.g., "a2b3c2" to "aabbbcc").
###### 53\. Implement a function to evaluate a mathematical expression (e.g., "3+5\*2").
###### 54\. Find the kth largest element in an unsorted list.
###### 55\. Implement a function to merge k sorted lists.
###### 56\. Find the median of two sorted arrays.
###### 57\. Implement a function to check if a string is a valid parenthesis sequence.
###### 58\. Generate all valid combinations of n pairs of parentheses.
###### 59\. Find the maximum sum subarray (Kadane’s algorithm).
###### 60\. Find the maximum product subarray.
###### 61\. Implement a function to perform a wildcard pattern matching.
###### 62\. Implement a function to perform regular expression matching.
###### 63\. Find the first missing positive integer in a list.
###### 64\. Find the maximum profit from buying and selling a stock once.
###### 65\. Find the maximum profit from buying and selling a stock multiple times.
###### 66\. Implement a function to solve the knapsack problem (0/1).
###### 67\. Implement a function to solve the knapsack problem (fractional).
###### 68\. Find the minimum number of coins to make a given amount.
###### 69\. Find the longest valid parentheses substring.
###### 70\. Implement a function to check if a number is a happy number.
###### 71\. Find all prime factors of a number.
###### 72\. Implement a function to solve the word ladder problem.
###### 73\. Find the shortest palindrome that can be formed by adding characters to a string.
###### 74\. Implement a function to perform a binary search on a rotated sorted array.
###### 75\. Find the peak element in an array (an element greater than its neighbors).
###### 76\. Implement a function to partition a list around a pivot (like in quicksort).
###### 77\. Find the maximum depth of a binary tree.
###### 78\. Find the diameter of a binary tree.
###### 79\. Implement a function to serialize and deserialize a binary tree.
###### 80\. Find the number of islands in a grid (using DFS or BFS).
###### 81\. Implement a function to perform a word search in a grid.
###### 82\. Find the minimum window substring containing all characters of another string.
###### 83\. Implement a function to calculate the square root of a number without using math.sqrt().
###### 84\. Find the k closest points to the origin in a 2D plane.
###### 85\. Implement a function to solve the sliding window maximum problem.
###### 86\. Find the maximum sum of a submatrix in a matrix.
###### 87\. Implement a function to check if a string is a valid number.
###### 88\. Find the longest consecutive sequence in an unsorted list.
###### 89\. Implement a function to perform a level-order traversal of a binary tree.
###### 90\. Find the maximum sum path from root to leaf in a binary tree.
###### 91\. Implement a function to check if a graph is bipartite.
###### 92\. Find the minimum number of jumps to reach the end of an array.
###### 93\. Implement a function to solve the Josephus problem.
###### 94\. Find the number of ways to climb n stairs (taking 1 or 2 steps at a time).
###### 95\. Implement a function to perform a binary search on a sorted matrix.
###### 96\. Find the maximum sum of a contiguous subarray with a given length.
###### 97\. Implement a function to check if a string is a valid IPv4 address.
###### 98\. Find the number of distinct subsequences in a string.
###### 99\. Implement a function to solve the egg dropping puzzle.
###### 100\. Find the minimum path sum in a grid from top-left to bottom-right.
######