Uploaded by kelly wakasa

Competitive coding Crash

advertisement
😈
Competitive coding Crash
DATE
DATE.
DATE..
Overall Covering
Project 1
Project 2
Project 3
Getting input
# Taking Integer as an input
n = int(input())
print("It is: ",n)
# Taking string as an input
s = input() # This input format is valid for python 3
print(s)
'''
Competitive coding Crash
1
Taking string of integers in ne line of known no. of input
a b c
1 2 3
'''
a,b,c = map(int,input().split())
print(a+b+c)
'''
Taking string of inntegers of any length as a list
a b c d
1 2 3 4
'''
#
__> The item that should be in list
#
|
____> Iteration of the input
#
|
|
all = [int(i) for i in input().split()] # List comprehension
sum=0
for i in all:
sum += i
print(sum)
'''
Other method to take in al as list is
'''
x= list(map(int,input().split()))
print(x)
'''
5
1 1 0 0 2
First take the first line as input which is 5
and then second line to take second input
'''
n = int(input()) #5
all = [int(i) for i in input().split()]
print(all)
'''
3
1
2
3
'''
n = int(input())
t = []
for i in range(n):
tc = int(input())
t.append(tc)
print(t)
'''
2
3
Competitive coding Crash
2
1 2
4
1 2
'''
q =
for
3
3 4
int(input()) # Number of quiries
i in range(q):
n = int(input()) # Input size
all = [int(i) for i in input().split()] # Elements of the list or array.
print(all) # oru iteration ku 1st set of inputla work pannum newt adutha iterationku n
est set of input
'''
4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
'''
n = int(input())
for i in range(n):
all = [int(i) for i in input().split()]
NOTES:
Efficiency: is how well u use the computer to do a task.
1. Space complexity
2. Time complexity
Notation:
O(n) - Big o notation
1. O(1) - Fastest
2. O(log(n)) - fast
3. O(n) - okay
4. O(n log(n))
- bad
5. O(n^2) - Horrible
Competitive coding Crash
3
ARRAY:
import array #module t use array
difference of array from list is, we can store same types of
data
Important Algorithms:
1. Depth first Search
2. Breath first search
3. Matching Parenthesis
4. Hash tables
5. Variable/ pointer manipulation
6. Reversing a Linked list
7. Sorting algorithms
8. Recursion
Competitive coding Crash
4
9. custom data structures
10. Binary search
Array Practice
TREE
sum of all nodes in a tree through recursion
Competitive coding Crash
5
Download