An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
March 30, 2022 07:40 pm GMT
Original Link: https://dev.to/hesoyamm/day-11-of-solving-450-questions450-3aed
day 11 of solving 450 questions[34/450]
Questions solved:
three-way-partitioning
two pointer approach.
left=left-1 increment only if find do same for right .
As I am going to begin with LinkedList: Wanted to freshen up on OOPS concept(has been a long time since last used it)
Beautiful Solution :
len(s)==len(goal) and goal in s+s
0(n) possible through KMP (not learned yet)
`species='mammal'
class Dog():
def init(self,breed,name):
self.breed=breed
self.name=name
- init can be thought as constructor for the class
- it will be called automatically when u create instance of a class
- self->represents as instance of the object itself.
- attribute
- we take in the argument
- assign it using self.attrivute_name
- operations/acitons----->method is a fn that is inside of class that will work with object in some waydef bark(self,number): print("WOOF! my name is {} and my number is {}".format(self.name,number))
my_dog=Dog('lab','Frankie')
notice this we are getting an error as we havent given any positional argument
because we are expecting breed parameter
so lets pass one
notice that attributes , never have () that because attributes it not something you execu
it is something you call back
print(my_dog.breed,my_dog.name)
my_dog.bark(10)
called method
class circle:
#clas sobject attribute
def __init__(self): self.pi=3.15def circumference(self,radius): return radius*self.pi*2
C=circle()
C.circumference(2)`
Original Link: https://dev.to/hesoyamm/day-11-of-solving-450-questions450-3aed
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To