This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def maxLength(self, ribbons: List[int], k: int) -> int: | |
low = 1 | |
high = max(ribbons) | |
result = 0 | |
while low <= high: | |
mid = (low+high)//2 | |
current = 0 | |
for ribbon in ribbons: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def validWordAbbreviation(self, word: str, abbr: str) -> bool: | |
i = 0 | |
j = 0 | |
number = 0 | |
while i < len(word) and j < len(abbr): | |
if abbr[j].isdigit(): | |
number = 10 * number + int(abbr[j]) | |
if number <= 0: | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BST: | |
def __init__(self, start, end): | |
self.start = start | |
self.end = end | |
self.left = None | |
self.right = None | |
class Solution: | |
def __init__(self): | |
self.root = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def merge(self, intervals: List[List[int]]) -> List[List[int]]: | |
if len(intervals) == 0: | |
return [] | |
if len(intervals) == 1: | |
return intervals | |
intervals.sort() | |
result = [intervals[0]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Sound from 'react-native-sound'; | |
Sound.setCategory('Playback'); | |
const sound = new Sound('http://example.com', (error) => { | |
if (error) { | |
// do something | |
} | |
// set volume |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_time(delay, task): | |
next_time = time.time() + delay | |
while True: | |
time.sleep(max(0, next_time - time.time())) | |
try: | |
task() | |
except Exception: | |
traceback.print_exc() | |
# skip tasks if we are behind schedule: | |
next_time += (time.time() - next_time) // delay * delay + delay |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addTodo(request): | |
receiver_email = "" | |
notification_time = "not available" | |
if request.POST['email_notification']: | |
receiver_email = request.POST['email_notification'] | |
if request.POST['todo_notification_time']: | |
notification_time = request.POST['todo_notification_time'] | |
sendEmail(request, receiver_email, notification_time) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index(request): | |
todo_items = Todo.objects.order_by('-due_date')[:10] | |
category_items = Category.objects.all() | |
notification_time = NotificationTime.objects.all() | |
current_date_time = datetime.now() | |
dt_string = current_date_time.strftime("%m/%d/%Y %I:%M %p") | |
splited_dt_string = dt_string.split(" ") | |
context = { | |
'todo_items': todo_items, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
app_name = 'todos' | |
urlpatterns = [ | |
path('', views.index, name='index'), | |
path('addTodo/', views.addTodo, name='addTodo'), | |
path('addCategory/', views.addCategory, name='addCategory'), | |
path('<int:todo_id>/edit/', views.edit, name='edit'), | |
path('<int:todo_id>/update/', views.update, name='update'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import datetime | |
class Category(models.Model): | |
category_name = models.CharField(max_length=100) | |
todo_count = models.IntegerField(default=0) | |
def __str__(self): | |
return self.category_name |
NewerOlder