text stringlengths 37 1.41M |
|---|
"""
Create a program that reads a real number and prints it.
"""
num = 4.4
print(f'Your number is {num}')
print(type(num))
|
'''
과제 번호 : 03
문제 내용 : 미니탁구
'''
import pygame
import sys
import random
SCREEN = pygame.display.set_mode((822,457))
class Paddle(pygame.sprite.Sprite):
def __init__(self,gamer,filename):
super().__init__()
self.image = pygame.image.load(filename).convert_alpha()
self.image = pygame.transf... |
#!/usr/bin/env python27
'''
Notes on FizzBuzz as implemented in Python
James Berger
February 16th, 2016
Sexy one liner found via Google:
for i in range(1,101): print "FizzBuzz"[i*i%3*4:8--i**4%5] or i
Terrible Python, but the fact that it's on one line is strangely appealing.
'''
# A more comprehensible solution to... |
# -*- coding: utf-8 -*-
'''
@brief: A board for Connect Four and abstract policies
@author: Evan Chow (created), Gabriel Huang (modified)
@data: May 2015
Currently does not work for diagonal wins (e.g. 5 in
a row along a diagonal).
'''
import numpy as np
class Board():
'''
The idea is that you place your p... |
#1) Function for parsing by left recursive method
#2) Parsing using FIRST and FOLLOWS
class CFG:
def __init__(self, **args):
self.terminals = args['terminals']
self.nonterminals = args['nonterminals']
self.start = args['start']
self.rules = args['rules']
#Function for parsing... |
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <markdowncell>
# ### Import libraries
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
# <markdowncell>
# ### Read Data
# read data into a DataFrame
data = pd.read_csv('Advertising.csv', index_col=0)
print(data.head(... |
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 28 11:10:15 2017
@author: Rohan
"""
#%%
def problem1_4(miles):
feet = miles * 5280
print("There are",feet,"feet in",miles,"miles.")
#%% |
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 29 17:51:18 2017
@author: Rohan
"""
#%%
def problem2_7():
""" computes area of triangle using Heron's formula. """
a = input("Enter length of side one: ")
a = float(int(a))
b = input("Enter length of side two: ")
b = float(int(b))
c = input(... |
#Author: Littl
# CreatedDate: 9th July 2021
# Example file for parsing and processing JSON
#
import urllib.request
import json
def printResults(data):
# Use the json module to load the string data into a dictionary
theJSON = json.loads(data)
# now we can access the contents of the JSON like any o... |
# Computer Programming 1
# Unit 11 - Graphics
#
# A scene that uses loops to make stars and make a picket fence.
# Imports
import pygame
import random
# Initialize game engine
pygame.init()
# Window
SIZE = (800, 600)
TITLE = "SNOWY DAYYY(press y)[ᵔĹ̯ᵔ] [ᵔĹ̯ᵔ] [ᵔĹ̯ᵔ] [ᵔĹ̯ᵔ] [ᵔĹ̯ᵔ] [ᵔL̯ᵔ] andrew.wilomo... |
def winning():
column_zero = [row[0] for row in game_matrix]
column_one = [row[1] for row in game_matrix]
column_two = [row[2] for row in game_matrix]
if column_zero == ["X", "X", "X"]:
return True
print ("X has won the game!")
elif column_zero == ["O", "O", "O"]:
return Tru... |
# Write a parse_date() function, which takes in a date string. The following
# 3 formats are accepted
# dd/mm/yyyy
# dd.mm.yyyy
# dd,mm,yyyy
#
# The function must return a dictionary with the 'd', 'm' and 'y' as keys
# like so:
# print(parse_date('22.12.2018'))
# {'d': '22', 'm': '12', 'y': '2018'}
import re
def pars... |
# Ask the user for a distance in km and convert that into miles.
print("Enter the distance in km:")
km = input() # input()-function returns a string
miles = float(km) / 1.609
#print(km + " km equals to " + str(miles) + " miles.")
print(f"{km} km equals to {miles} miles.")
|
# Write a function called divide, which accepts two parameters (you can call
# them num1 and num2). The function should return the result of num1 divided
# by num2. If you do not pass the correct amount of arguments to the function,
# it should return the string "Please provide two integers or floats". If you
# pas... |
"""More comprehension exercises"""
def flip_dict(orig_dict):
"""Return a new dictionary that maps the original values to the keys."""
return {v: k for k, v in orig_dict.items()}
def get_ascii_codes(list_of_strings):
"""Return a dictionary mapping the strings to ASCII codes."""
output_dictionary = {... |
# This program uses the classes defined in the file database.py and
# implements a menu like interface for working with the SwimDataBase
from database import Record, SwimDataBase
from sys import exit
class Menu:
'Asks the user for desired action and carries it out.'
def __init__(self):
self.d1 = Swim... |
# This week I want you to make a class that represents a circle.
#
# The circle should have a radius, a diameter, and an area. It should also
# have a nice string representation.
#
# For example:
#
# >>> c = Circle(5)
# >>> c
# Circle(5)
# >>> c.radius
# 5
# >>> c.diameter
# 10
# >>> c.area
# 78.53981633974483
#
#... |
# Another decorator exercise. The decorator only_ints() must return
# "Please only invoke with integers." in case some of the arguments is
# not an integer. Otherwise it must execute the input function normally.
#
# @only_ints
# def add(x, y):
# return x + y
#
# add(1, 2) # 3
# add("1", "2") # "Please only invoke... |
# I'd like you to write a function that accepts two lists-of-lists of numbers
# and returns one list-of-lists with each of the corresponding numbers in the
# two given lists-of-lists added together.
#
# It should work something like this:
#
# >>> matrix1 = [[1, -2], [-3, 4]]
# >>> matrix2 = [[2, -1], [0, -1]]
# >>> a... |
def say(name,*args):
print("我是%s" % (name))
for arg in args:
print(arg)
def say02(name, **kwargs):
print("我是%s" % (name))
for key in kwargs:
print("key:%s" % (key))
def say03(name,name2='hihi', *args, **kwargs):
print("我是%s" % (name))
for arg in args:
print(arg)
f... |
n = int(input("Enter number of lines: "))
for i in range(1, n):
print(i**n + '\t') |
import pygame
class ball(object):
"""Class of the ball"""
def __init__(self):
"""Initialize x, y, free, vel_x, vel_y
lives_count variables"""
self.x = 400
self.y = 460
self.free = False
self.vel_x = 0
self.vel_y = 0
self.lives_count = 3
def ... |
#!/usr/bin/env python3
# coding=utf-8
def is_divisable(a, b=3):
return a == a // b * b
def main():
number = int(input())
print("YES" if is_divisable(number) else "NO")
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
# coding=utf-8
def main():
n = int(input())
if (-15 < n <= 12 or 14 < n < 17 or
19 <= n):
print(True)
else:
print(False)
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
def main():
student_marks = input().strip().split()
print("{:.2f}".format(student_marks.count("A") / len(student_marks)))
if __name__ == "__main__":
main() |
#!/usr/bin/env python3
def main():
n = int(input())
# sum of sequence 1, -0.5, 0.25, -0.125 ...
print(sum([(-1 / 2) ** i for i in range(n)]))
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
# coding=utf-8
def print_cube_path(a, b):
def inverse(a, i):
return "0" if a[i] == "1" else "1"
k = len(a)
cube_visited = {}
cube_visited[a] = True
for i in range(k):
print(a, end=" ")
neighbour = a[:i] + inverse(a, i) + a[i + 1:]
print(nei... |
#!/usr/bin/env python3
# coding=utf-8
import sys
import collections
def latin_spanish_dict(n_words, reader):
for _ in range(n_words):
term, descript = next(reader).split(" - ")
# tuple of "latin keyword", "description"
yield term, map(str.strip, descript.split(", "))
def spanish_latin_... |
#!/usr/bin/env python3
# coding=utf-8
import sys
class Deque(list):
def push_front(self, x):
super().insert(0, x)
def pop_front(self):
return self._pop(0)
def push_back(self, x):
super().append(x)
def pop_back(self):
return self._pop(-1)
def _pop(self, index):... |
#!/usr/bin/env python3
# coding=utf-8
import sys
def main():
reader = (line for line in open("dataset_28255_1.txt"))
with open("output_28255_1.txt", "w") as f:
for line in reversed(list(reader)):
print(line, file=f, end="")
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
# coding=utf-8
import sys
import math
def circle():
radius = int(input())
pi = 3.14
return pi * radius ** 2
def rectangle():
length = int(input())
width = int(input())
return length * width
def triangle():
reader = (int(line) for line in sys.stdin)
a, b, c... |
#!/usr/bin/env python3
# coding=utf-8
import sys
def find_smallest_end(num1, num2, n1_i, n2_i):
while n1_i < len(num1) and n2_i < len(num2):
if num1[n1_i] < num2[n2_i]:
return True
elif num1[n1_i] > num2[n2_i]:
return False
n1_i += 1
n2_i += 1
return ... |
import turtle
import numpy as np
from PIL import Image, ImageEnhance
def whiteToAlpha(img):
""" renders white background of image transparent
found under http://stackoverflow.com/questions/765736/using-pil-to-make-all-white-pixels-transparent """
img = img.convert("RGBA")
datas = img.getdata()
newData =... |
# Recursion : Function calling itself is called recursion
def fact(n):
if n == 0:
return 1
return n * fact(n-1)
result = fact(4)
print(result)
|
# Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered,
# print out the largest and smallest of the numbers.
# If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number.
# E... |
num = float(input('enter a number'))
cu = num * num * num
print('the cube of',num,'is :',cu)
|
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3321/
# Given an array of size n, find the majority element.
# The majority element is the element that appears more than ⌊ n/2 ⌋ times.
# You may assume that the array is non-empty and the majority element always exist... |
# https://leetcode.com/explore/challenge/card/april-leetcoding-challenge-2021/594/week-2-april-8th-april-14th/3706/
# Flatten Nested List Iterator
# You are given a nested list of integers nestedList. Each element is either an integer or
# a list whose elements may also be integers or other lists. Implement an iter... |
# https://leetcode.com/problems/sum-of-even-numbers-after-queries/description/
# 985. Sum of Even Numbers After Queries
# We have an array A of integers, and an array queries of queries.
# For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index]. Then, the answer to the i-th query
# i... |
# https://leetcode.com/problems/binary-gap/description/
# 868. Binary Gap
# Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.
# If there aren't two consecutive 1's, return 0.
# Example 1:
# Input: 22
# Output: 2
# Explanation:
# 22 in bin... |
# https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3502/
# Asteroid Collision
# We are given an array asteroids of integers representing asteroids in a row.
# For each asteroid, the absolute value represents its size, and the sign represents its direction... |
# https://leetcode.com/problems/bag-of-tokens/description/
# 948. Bag of Tokens
# You have an initial power P, an initial score of 0 points, and a bag of tokens.
# Each token can be used at most once, has a value token[i], and has potentially two ways to use it.
# If we have at least token[i] power, we may play th... |
# https://leetcode.com/problems/flipping-an-image/description/
# 832. Flipping an Image
# Given a binary matrix A, we want to flip the image horizontally, then invert it, and return
# the resulting image.
# To flip an image horizontally means that each row of the image is reversed. For example,
# flipping [1, 1, ... |
# https://leetcode.com/problems/goat-latin/description/
# 824. Goat Latin
# A sentence S is given, composed of words separated by spaces. Each word consists of lowercase
# and uppercase letters only.
# We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.)
# The rules of ... |
# https://leetcode.com/problems/play-with-chips/description/
# 1217. Play with Chips
# There are some chips, and the i-th chip is at position chips[i].
# You can perform any of the two following types of moves any number of times (possibly zero) on any chip:
# Move the i-th chip by 2 units to the left or to the rig... |
# https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/588/week-1-march-1st-march-7th/3657/
# Distribute Candies
# Alice has n candies, where the ith candy is of type candyType[i].
# Alice noticed that she started to gain weight, so she visited a doctor.
# The doctor advised Alice to only e... |
# https://leetcode.com/problems/fair-candy-swap/description/
# 888. Fair Candy Swap
# Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of
# candy that Bob has.
# Since they are friends, they would like to exchange one ca... |
# https://leetcode.com/problems/degree-of-an-array/description/
# 697. Degree of an Array
# Given a non-empty array of non-negative integers nums, the degree of this array is defined
# as the maximum frequency of any one of its elements.
# Your task is to find the smallest possible length of a (contiguous) subarray... |
# https://leetcode.com/problems/largest-triangle-area/description/
# 812. Largest Triangle Area
# You have a list of points in the plane. Return the area of the largest triangle that
# can be formed by any 3 of the points.
# Example:
# Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]]
# Output: 2
# Explanation:
# ... |
# Leetcode 55 -- Jump Game
# Given an array of non-negative integers, you are initially positioned at the first index of the array.
# Each element in the array represents your maximum jump length at that position.
# Determine if you are able to reach the last index.
# For example:
# A = [2,3,1,1,4], return true. A =... |
# https://leetcode.com/problems/reverse-words-in-a-string-iii/description/
# 557. Reverse Words in a String III
# Given a string, you need to reverse the order of characters in each word within
# a sentence while still preserving whitespace and initial word order.
# Example 1:
# Input: "Let's take LeetCode contest"... |
# Leetcode 70 -- Climbing Stairs
# You are climbing a stair case. It takes n steps to reach to the top.
# Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
#solution 1 toooo slow
import itertools
def climbStairs(n):
"""
:type n: int
:rtype: int
"""
... |
# https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/590/week-3-march-15th-march-21st/3673/
# Encode and Decode TinyURL
# Note: This is a companion problem to the System Design problem: Design TinyURL.
# TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/p... |
# https://leetcode.com/explore/challenge/card/november-leetcoding-challenge/564/week-1-november-1st-november-7th/3522/
# Add Two Numbers II
# You are given two non-empty linked lists representing two non-negative integers.
# The most significant digit comes first and each of their nodes contain a single digit.
# A... |
# https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/549/week-1-august-1st-august-7th/3414/
# Find All Duplicates in an Array
# Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
# Find all the elements that appear twice in this array.... |
# https://leetcode.com/problems/maximum-product-of-three-numbers/#/description
# Given an integer array, find three numbers whose product is maximum and output the maximum product.
# Example 1: Input: [1,2,3] Output: 6
# Example 2: Input: [1,2,3,4] Output: 24
# Note:
# The length of the given array will be in... |
# https://leetcode.com/problems/day-of-the-year/description/
# 1154. Day of the Year
# Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD,
# return the day number of the year.
# Example 1:
# Input: date = "2019-01-09"
# Output: 9
# Explanation: Given date is the 9th day of the year ... |
# https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/547/week-4-july-22nd-july-28th/3398/
# Binary Tree Zigzag Level Order Traversal
# Given a binary tree, return the zigzag level order traversal of its nodes' values.
# (ie, from left to right, then right to left for the next level and alternate b... |
# https://leetcode.com/explore/featured/card/september-leetcoding-challenge/554/week-1-september-1st-september-7th/3445/
# Largest Time for Given Digits
# Given an array of 4 digits, return the largest 24 hour time that can be made.
# The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00... |
# https://leetcode.com/contest/leetcode-weekly-contest-32/problems/shortest-unsorted-continuous-subarray/
# Given an integer array, you need to find one continuous subarray that if you only sort this subarray
# in ascending order, then the whole array will be sorted in ascending order, too.
# You need to find the sho... |
# https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/572/week-4-december-22nd-december-28th/3580/
# Diagonal Traverse
# Given a matrix of M x N elements (M rows, N columns),
# return all elements of the matrix in diagonal order as shown in the below image.
# Example:
# Input:
# [
# [ 1, 2, ... |
# https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/557/week-4-september-22nd-september-28th/3472/
# Largest Number
# Given a list of non negative integers, arrange them such that they form the largest number.
# Example 1:
# Input: [10,2]
# Output: "210"
# Example 2:
# Input: [3,30,34,5,9]... |
# https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/570/week-2-december-8th-december-14th/3559/
# Pairs of Songs With Total Durations Divisible by 60
# You are given a list of songs where the ith song has a duration of time[i] seconds.
# Return the number of pairs of songs for which their tot... |
# https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/581/week-3-january-15th-january-21st/3610/
# Valid Parentheses
# Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
# An input string is valid if:
# Open brackets mus... |
# https://leetcode.com/problems/minimum-cost-to-connect-sticks/description/
# 1167. Minimum Cost to Connect Sticks
# You have some sticks with positive integer lengths.
# You can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y.
# You perform this action until there is one stick ... |
# https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/586/week-3-february-15th-february-21st/3643/
# Container With Most Water
# Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai).
# n vertical lines are drawn such that the two endpoints of ... |
# https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/556/week-3-september-15th-september-21st/3465/
# Sequential Digits
# An integer has sequential digits if and only if each digit in the number is one more than the previous digit.
# Return a sorted list of all the integers in the range [low, ... |
# https://leetcode.com/problems/reverse-vowels-of-a-string/description/
# 345. Reverse Vowels of a String
# Write a function that takes a string as input and reverse only the vowels of a string.
# Example 1:
# Given s = "hello", return "holle".
# Example 2:
# Given s = "leetcode", return "leotcede".
# Note:
# The ... |
# https://leetcode.com/explore/challenge/card/september-leetcoding-challenge/558/week-5-september-29th-september-30th/3478/
# First Missing Positive
# Given an unsorted integer array, find the smallest missing positive integer.
# Example 1:
# Input: [1,2,0]
# Output: 3
# Example 2:
# Input: [3,4,-1,1]
# Output: 2
... |
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3319/
# Given a positive integer, output its complement number.
# The complement strategy is to flip the bits of its binary representation.
# Example 1:
# Input: 5
# Output: 2
# Explanation: The binary representation ... |
# https://leetcode.com/problems/decrease-elements-to-make-array-zigzag/description/
# 1144. Decrease Elements To Make Array Zigzag
# Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.
# An array A is a zigzag array if either:
# Every even-indexed element is greater than... |
# https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/547/week-4-july-22nd-july-28th/3403/
# Construct Binary Tree from Inorder and Postorder Traversal
# Given inorder and postorder traversal of a tree, construct the binary tree.
# Note:
# You may assume that duplicates do not exist in the tree.
#... |
# https://leetcode.com/problems/verifying-an-alien-dictionary/description/
# 953. Verifying an Alien Dictionary
# In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order.
# The order of the alphabet is some permutation of lowercase letters.
# Given a sequence of... |
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3317/
# You're given strings J representing the types of stones that are jewels,
# and S representing the stones you have. Each character in S is a type of stone you have.
# You want to know how many of the stones you... |
# Arranging Coins
# You have a total of n coins that you want to form in a staircase shape,where every k-th row must have exactly k coins.
# Given n, find the total number of full staircase rows that can be formed.
# n is a non-negative integer and fits within the range of a 32-bit signed integer.
# Example 1:
# n = ... |
# https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/description/
# 1155. Number of Dice Rolls With Target Sum
# You have d dice, and each die has f faces numbered 1, 2, ..., f.
# Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum
# of the face up n... |
# https://leetcode.com/problems/shift-2d-grid/description/
# 1260. Shift 2D Grid
# Given a 2D grid of size n * m and an integer k. You need to shift the grid k times.
# In one shift operation:
# Element at grid[i][j] becomes at grid[i][j + 1].
# Element at grid[i][m - 1] becomes at grid[i + 1][0].
# Element at grid... |
# Leetcode 9 -- Palindrome Number
# Determine whether an integer is a palindrome. Do this without extra space.
def isPalindrome(x):
"""
:type x: int
:rtype: bool
"""
if x < 0: return False
div = 1
while x/div >= 10:
div = div * 10
while x:
if x / div != x % 10:
... |
#leetcode 231 -- Power of Two
#Given an integer, write a function to determine if it is a power of two.
def isPowerOfTwo(n):
"""
:type n: int
:rtype: bool
"""
## solution 1
if n <= 0: return False
while n % 2 == 0:
n /= 2
return n == 1
## solution 2
if n <= 0: return F... |
# https://leetcode.com/contest/leetcode-weekly-contest-41/problems/maximum-average-subarray-i/
# 643. Maximum Average Subarray I
# Given an array consisting of n integers, find the contiguous subarray of given length k that has the
# maximum average value. And you need to output the maximum average value.
# Example... |
# https://leetcode.com/explore/challenge/card/december-leetcoding-challenge/573/week-5-december-29th-december-31st/3587/
# Largest Rectangle in Histogram
# Given n non-negative integers representing the histogram's bar height where the width of each bar is 1,
# find the area of largest rectangle in the histogram.
... |
# Leetcode 263 -- Ugly Number
# https://leetcode.com/problems/ugly-number/description/
# Write a program to check whether a given number is an ugly number.
# Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
#For example, 6, 8 are ugly while 14 is not ugly since it includes another prime fac... |
# https://leetcode.com/contest/leetcode-weekly-contest-28/problems/student-attendance-record-i/
def checkRecord(s):
"""
:type s: str
:rtype: bool
"""
return s.count('A') <= 1 and s.count('LLL') == 0
print checkRecord("LLAA") # False
print checkRecord("PPPLLPAA") # False
print checkRecord("PPALLP") # True
print c... |
# https://leetcode.com/explore/challenge/card/april-leetcoding-challenge-2021/593/week-1-april-1st-april-7th/3698/
# Minimum Operations to Make Array Equal
# You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n).
# In one operation, you can select two indices x an... |
# https://leetcode.com/problems/max-area-of-island/description/
# 695. Max Area of Island
# Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.)
# You may assume all four edges of the grid are surrounded by water.
# Find ... |
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/536/week-3-may-15th-may-21st/3333/
# Permutation in String
# Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1.
# In other words, one of the first string's permutations is the substring of the secon... |
# https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/583/week-5-january-29th-january-31st/3623/
# Next Permutation
# Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
# If such an arrangement is not possible, it must rearra... |
# https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/582/week-4-january-22nd-january-28th/3615/
# Merge k Sorted Lists
# You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
# Merge all the linked-lists into one sorted linked-list and return it.
... |
# https://leetcode.com/problems/daily-temperatures/description/
# 739. Daily Temperatures
# Given a list of daily temperatures, produce a list that, for each day in the input, tells you
# how many days you would have to wait until a warmer temperature. If there is no future day for
# which this is possible, put 0 i... |
# https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/549/week-1-august-1st-august-7th/3411/
# Valid Palindrome
# Given a string, determine if it is a palindrome,
# considering only alphanumeric characters and ignoring cases.
# Note: For the purpose of this problem, we define empty string as val... |
# https://leetcode.com/explore/challenge/card/april-leetcoding-challenge-2021/594/week-2-april-8th-april-14th/3705/
# Beautiful Arrangement II
# Given two integers n and k, you need to construct a list which contains n different
# positive integers ranging from 1 to n and obeys the following requirement:
# Suppose ... |
# https://leetcode.com/explore/challenge/card/july-leetcoding-challenge/547/week-4-july-22nd-july-28th/3402/
# Add Digits
# Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
# Example:
# Input: 38
# Output: 2
# Explanation: The process is like: 3 + 8 = 11, 1 + 1 = ... |
# https://leetcode.com/problems/next-greater-element-ii/description/
# 503. Next Greater Element II
# Given a circular array (the next element of the last element is the first element of the array),
# print the Next Greater Number for every element. The Next Greater Number of a number x is the first
# greater numb... |
# https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/551/week-3-august-15th-august-21st/3431/
# Sort Array By Parity
# Given an array A of non-negative integers, return an array consisting of all the even elements of A,
# followed by all the odd elements of A.
# You may return any answer array ... |
# https://leetcode.com/explore/challenge/card/april-leetcoding-challenge-2021/593/week-1-april-1st-april-7th/3697/
# Global and Local Inversions
# We have some permutation A of [0, 1, ..., N - 1], where N is the length of A.
# The number of (global) inversions is the number of i < j with 0 <= i < j < N and A[i] > A[... |
# https://leetcode.com/explore/challenge/card/november-leetcoding-challenge/564/week-1-november-1st-november-7th/3521/
# Find the Smallest Divisor Given a Threshold
# Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and
# divide all the array by it and sum the resu... |
# Leetcode 171. Excel Sheet Column Number
# https://leetcode.com/problems/excel-sheet-column-number/#/description
# Related to question Excel Sheet Column Title
# Given a column title as appear in an Excel sheet, return its corresponding column number.
# For example:
# A -> 1
# B -> 2
# C -> 3
# ...
#... |
# https://leetcode.com/problems/rotated-digits/description/
# 788. Rotated Digits
# X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that
# is different from X. Each digit must be rotated - we cannot choose to leave it alone.
# A number is valid if each digit remai... |
# https://leetcode.com/problems/string-without-aaa-or-bbb/description/
# 984. String Without AAA or BBB
# Given two integers A and B, return any string S such that:
# S has length A + B and contains exactly A 'a' letters, and exactly B 'b' letters;
# The substring 'aaa' does not occur in S;
# The substring 'bbb' d... |
# https://leetcode.com/explore/challenge/card/may-leetcoding-challenge-2021/600/week-3-may-15th-may-21st/3749/
# Binary Tree Level Order Traversal
# Given the root of a binary tree,
# return the level order traversal of its nodes' values.
# (i.e., from left to right, level by level).
# Example 1:
# Input: root ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.