text
stringlengths
37
1.41M
casos=int(input()) for caso in range(casos): entrada=input() ricardo,vicente=entrada.split() x=int(ricardo) y=int(vicente) divisor_comun = 1 while divisor_comun <= x and divisor_comun <= y: if x % divisor_comun == 0 and y % divisor_comun == 0: divisor_final = divisor_comun ...
entrada=input() pedidos=input() a,b,c=entrada.split() d,e,f=pedidos.split() a=int(a) b=int(b) c=int(c) d=int(d) e=int(e) f=int(f) falta=0 if a<d: falta=falta+(d-a) if b<e: falta=falta+(e-b) if c<f: falta=falta+(f-c) print(falta)
dist=float(input("Insira a distância: ")) quantidade=int(input("Insira a quantidade de carros a serem comparados: ")) teste=1 nome=[] velocidade=[] velocidade_teste=0 while (teste<=quantidade): teste=teste+1 carro_nome=input("Insira o nome do carro: ") nome.append(carro_nome) tempo=float(input("Insira o...
altura=float(input("Digite sua altura: ")) sexo=input("Digite M ou F") if sexo=="M": pesoHomem=(72.7 * altura)-58 print(f"Peso ideal {pesoHomem}") elif sexo=="F": pesoMulher=(62.1*altura)-44.7 print(f"Peso ideal {pesoMulher}")
while True: ent=input() a,b=ent.split() a=int(a) b=int(b) if a==0 and b==0: break
#Calcula o preço da compra de vários clientes numero_clientes=int(input("Insira o número total de clientes: ")) cliente_atual=1 while cliente_atual<=numero_clientes: adicionar="SIM" total=0 while adicionar.upper()=="SIM": print(f"Compra do cliente {cliente_atual}: ") preco=float(input("Insir...
#TESTE 1 #PARECE ESTAR FUNCIONAND, PORÉM ACHO QUE OPDE REDUZIR O CÓDIGO n1=int(input("Insira o primeiro número: ")) n2=int(input("Insira o segundo número: ")) n1_resultado=[] n2_resultado=[] n1_marcador=2 n2_marcador=2 while (n1_marcador<=n1): n1_teste=n1/n1_marcador if n1%n1_marcador==0: n1_resultado.a...
a= [1, 2, 3] b= [5,6,7,8] c= [1,2] print(a) print(b) print(c) print ("chain a b") import itertools for x in itertools.chain(a,b): print(x) print ("chain zip c b") for x in itertools.chain(*zip(c,b)): print(x) print ("chain zip c (",c, ") cycle b (",b,")") for x in itertools.chain(*zip(c,itertools.cycle(b))): print(...
''' Create a function called max_num() that has three parameters named num1, num2, and num3. The function should return the largest of these three numbers. If any of two numbers tie as the largest, you should return "It's a tie!".''' # Write your max_num function here: # Uncomment these function calls to test your...
'''Create a function named large_power() that takes two parameters named base and exponent. If base raised to the exponent is greater than 5000, return True, otherwise return False''' # Write your large_power function here: # Uncomment these function calls to test your large_power function: def large_power(base,e...
'''Create a function called tip() that has two parameters named total and percentage. This function should return the amount you should tip given a total and the percentage you want to tip.''' # Write your tip function here: # Uncomment these function calls to test your tip function: def tip(total,percentage): ...
''' Write a function named max_key that takes a dictionary named my_dictionary as a parameter. The function should return the key associated with the largest value in the dictionary. '''' HInt: Begin by creating two variables named largest_key and largest_value. Initialize largest_value to be the smallest number pos...
class animal(object): def __init__ (self,name,health): self.name = name self.health = health def walk(self): self.health -= 1 return self def run(self): self.health -= 5 return self def display_health(self): print self.health animal1 = animal('cat', 100).walk().walk().run().run().display_health() cl...
import re def tokenize_from_file_name(fname): with open(fname) as f: text = f.read() return re.findall('([A-Za-z]+|[",.!;:?])', text) def tokenize_from_file(f): text = f.read() return re.findall('([A-Za-z]+|[",.!;:?])', text)
#encoding=utf-8 class ResultIndex(object): def CountIndex(self): alist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] item = 7 startIndex = 0 endIndex = len(alist) - 1 while endIndex >= startIndex: mid = (startIndex + endIndex)/2 gu...
name = 1 points = [] class Point(object): x = 0 y = 0 index = 0 def __init__(self, x, y): ''' :param x: float :param y: float ''' for point in points: if point.x == x and point.y == y: self.x = x self.y = y ...
""" An array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. Your goal is to find that missing element. Write a function: def solution(A) that, given an array A, returns the value of the missing element. For exam...
# coding=utf-8 """ This is a demo task. Write a function: def solution(A) that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4...
""" Halfling Woolly Proudhoof is an eminent sheep herder. He wants to build a pen (enclosure) for his new flock of sheep. The pen will be rectangular and built from exactly four pieces of fence (so, the pieces of fence forming the opposite sides of the pen must be of equal length). Woolly can choose these pieces out of...
""" Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Example 1: Input: [1,3,5,6], 5 Output: 2 Example 2: Input: [1,3,5,6], 2 Output: 1 Example 3: Input: [1,3,5,6], 7 O...
""" 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 instead. For example, given the list temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your outpu...
''' An array A consisting of N integers is given. The dominator of array A is the value that occurs in more than half of the elements of A. For example, consider array A such that A[0] = 3 A[1] = 4 A[2] = 3 A[3] = 2 A[4] = 3 A[5] = -1 A[6] = 3 A[7] = 3 The dominator of A is 3 because it occurs in 5...
''' An array A consisting of N integers is given. A triplet (P, Q, R) is triangular if it is possible to build a triangle with sides of lengths A[P], A[Q] and A[R]. In other words, triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and: A[P] + A[Q] > A[R], A[Q] + A[R] > A[P], A[R] + A[P] > A[Q]. For example, conside...
''' A non-empty array A consisting of N integers is given. A triplet (X, Y, Z), such that 0 ≤ X < Y < Z < N, is called a double slice. The sum of double slice (X, Y, Z) is the total of A[X + 1] + A[X + 2] + ... + A[Y − 1] + A[Y + 1] + A[Y + 2] + ... + A[Z − 1]. For example, array A such that: A[0] = 3 A[1] ...
import time as dt import matplotlib.pyplot as plt import pandas as pd df = pd.read_excel(r'Path to the File') print("The DataSet To be Sorted using SELECTION SORT") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print(df) print("---------------------------------------------") n=input("Enter the Attribute Name ...
import pygame from Game.Shared.GameConstants import GameConstants import random class Cactus(object): def __init__(self): """ The constructor of the class """ self.x = 0 self.y = 0 self.width = 0 self.height = 0 self.index = 0 def handle_moves(self): "...
x=1 y=1 z=0 places=int(input('how many numbers?(max 15): ')) if places==1: print('0') elif places<16 and places>1: print('0', end=' ') for places in range (1,places): if z%2>0: print(x, end=' ') x=x+y z+=1 else: print(y, end=' ') ...
# Using the Luhn Algorithm # The way we're going to use the algorithm is as follows: # 1) Remove the rightmost digit from the card number. # This number is called the checking digit, and it will be excluded from most of our calculations. # 2) Reverse the order of the remaining digits. # 3) For this sequence of reve...
# Style note *** # It's common convention to name a loop variable '_' when the number being generated # is not in the code of the loop body # e.g.: # for _ in range(10): # print('Hola') # Exercises # 1) Below we've provided a list of tuples, where each tuple contains details about an # employee of a shop: their name...
# -*- coding: utf8 -*- print("--- Python 101 - Séance 3 ---") print("-----------------------------") # Revisions print("--- Révisions -") print('Let\'s go') nom = input("Comment t'appelles-tu ? ") print('Let\'s go go {}'.format(nom)) print("Ceci est un integer : {}".format(4)) print("Ceci est un float : {}".format(4...
""" Introduction There is a war and nobody knows - the alphabet war! There are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began. Task Write a function that accepts fight string consists of only small letters and return who wins the fight. When ...
""" You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value. The returned value must be a string, and have "***" between each of its letters. You should not remove or add elements from/to the array. Source: co...
import random print("How's it going fella? We're gonna play the game 'Guess the Number', where you try to guess a number I am thinking. What can I call you?") #introduces the game and asks for the player's name playersname=input() #gives the player's name a variable to be used next in referencing the player by the na...
print("=====MASUKKAN JUMLAH MAKANAN YANG DIPESAN=====") IB = int(input("IKAN BAKAR Rp 25.000,00 : ")) ED = int(input("ES DOGER Rp 6.000,00 : ")) RC = int(input("RUJAK CINGUR Rp 8.000,00 : ")) print("=====TOTAL=====") IB2 = IB*25000 ED2 = ED*6000 RC2 = RC*8000 print("TOTAL IKAN BAKAR : Rp",IB2) print("TOTAL ES DOGER...
class Animal(object): def __init__(self, name): self.name = name super(Animal, self).__init__() def eat(self, food): print ("{0} eats {1}".format(self.name, food)) class Dog(Animal): def fetch(self, thing): return "{0} goes after the {1}". format(self.name, thing) class C...
def perimeter(length, width): """ Return perimeter of square or rect :param length: :type length: float|int :param width: :type width: float|int :return: Perimeter :rtype: float|int """ return 2 * length + 2 * width
from collections import deque import sys def read(): return sys.stdin.readline().rstrip() def rotate(i, k): # 시계방향 회전 global board for _ in range(k): last = board[i].pop() board[i].appendleft(last) def find_targets(): global N, M, board # 인접하면서 같은 수를 찾는다. # 하나라도 있으면 t...
def solution(s): def to_jaden(x): if x == '': return x jaden = x.lower() if x[0].isalpha() == False: return jaden return jaden[0].upper() + jaden[1:] li = list(map(to_jaden, s.split(' '))) return ' '.join(li) print(solution("A aa aa 1aA aaa bxdd...
from collections import deque import heapq def solution(jobs): heap = [] job_queue = deque(sorted(jobs)) time = 0 answer = 0 # current = [전체 작업시간,요청받은 시간, 남은 작업 시간] current = None while not (len(job_queue) == 0 and len(heap) == 0 and current == None): # job_queue에서 heap으로 작업 할당...
def solution(fees, records): [basic_minutes, basic_fee, unit_minutes, unit_fee] = list(map(int, fees)) parking_lot = dict() car_in_minutes = dict() def calculate_fee(minutes): if minutes <= basic_minutes: return basic_fee unit = 0 if (minutes-basic_minutes) % unit_...
# Assignment: Product # Objectives: # Practice creating a class and making instances from it # Practice accessing the methods and attributes of different instances # Practice altering an instance's attributes # The owner of a store wants a program to track products. Create a product class to fill the following requirem...
# -*- coding: utf-8 -*- """Escribir un programa que pregnte el nombre del usuario en la consola y despues de que el usuario por pantalla la cadena "Hola Nombre ", donde nombre, es el nombre que el usuario haya elegido """ name = input("Introduce tu nombre: ") print("¡Hola" + name + "!")
# import csv import pandas def main(): # with open("weather_data.csv", 'r') as weather_data: # data = csv.reader(weather_data) # temperatures = [] # #print(data.line_num) # for row in data: # if row[1].isnumeric(): # temperatures.append(int(row[1])) ...
# Print only squared result from numbers list def squaring(): numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] squared_numbers = [num**2 for num in numbers] print(f"Squared numbers: {squared_numbers}") # Print only even numbers from numbers list def filter_even(): numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, ...
from tkinter import * from tkinter import messagebox from random import choice from pyperclip import copy import json import string # INSECURE VERSION OF A PASSWORD MANAGER OF COURSE. DON'T SAVE PASSWORDS # # WITHOUT ENCRYPTION.... EVER! # PASSWORD_FILE = "myPasswords....
from tkinter import * import math PINK = "#e2979c" RED = "#e7305b" GREEN = "#9bdeac" YELLOW = "#f7f5dd" FONT_NAME = "Courier" WORK_MIN = 25 SHORT_BREAK_MIN = 5 LONG_BREAK_MIN = 20 reps = 0 timer = None def main(): # ---------------------------- TIMER RESET ------------------------------- # def reset_timer():...
import random def guessing_game( ): answer = random.randint(0, 100) while True: try: user_guess = int( input ( 'Your guess? ') ) except ValueError: print("It must be an integer") else: if user_guess == answer: print(f"Right!...
Modi = 'MODI' names = ['Obama', "Hillary", Modi, 'Putin', 'MODI'] print names names.append('Mao') print names.count(Modi) print names t = ('Indira', 'Bill') r = ['Lal', 'Bill'] names.extend(t) print names names.extend(r) print names print "Index : ", names.index('MODI', 3, 5) print len(names) names.insert(5, 'MO...
from random import randint import json def displayWelcome(data_list): print("\n--- Welcome to Hangman - League of Legends version!---") print(f"\nCurrently there are {len(data_list)} champions as of version 11.11") print("Try to guess a champion's name from an ability") print('You can type "/ff" to sur...
#!/usr/bin/env python3 import sys def ip_checker(ip:str)->bool: segments=ip.split('.') if 4 != len(segments): print(f"{ip} is segmented into {segments}") return False for x in segments: if x.isnumeric(): x_integer = int(x) if x_integer < 1 or x_integer >= 25...
'''4. Определить, какое число в массиве встречается чаще всего.''' from random import random arr_length = int(input('Please insert desired array length\n' 'in range from 5 to 50: ')) # user input for array length print() array = [[0] * arr_length for i in range(arr...
'''2. Выполнить логические побитовые операции «И», «ИЛИ» и др. над числами 5 и 6. Выполнить над числом 5 побитовый сдвиг вправо и влево на два знака. Объяснить полученный результат. logic OR 5 - 101 logic AND 101 logic XOR 101 6 - 110 110 110 --- --- ...
''' 3. Сформировать из введенного числа обратное по порядку входящих в него цифр и вывести на экран. Например, если введено число 3486, то надо вывести число 6843. ''' print('reverse number inserted by user') num = int(input('type in number to reverse: ')) rev_num = 0 while num > 0: rev_num = rev_num*10 + num % 10...
def search(L,key): n = 0 for i in L: if i == key: return n n += 1 return -1 #程序 while 1: L1 = [12,14,134,21,4,124,112,41,2,3412,34,1243] key = int(input("待查找的数是:")) n = search(L1,key) if n == -1: print("没找到") else: print(key,"是下标为%d的元素" %n)
print("计算最大公因数。") while True: a=int(input("请输入一个正整数:")) b=int(input("请输入另一个正整数:")) if a<=0 or b<=0: break while a!=b: if a>b: a=a-b else: b=b-a print("公因数为:",a) print("程序结束。")
def make(n): sumn=0 while n>=1: sumn=sumn+n n=n-1 return sumn print("数列求和") while True: n=int(input("请输入一个正整数")) print("结果为",make(n)) print()
print("这是一个计算最大值最小值平均值的程序") L=[17,38,20,16,3,24,30,44,-10,12] N=len(L) minl=L[0] maxl=L[0] suml=L[0] for i in range (1,N): if minl>L[i]: minl=L[i] if maxl<L[i]: maxl=L[i] suml=suml+L[i] ave=suml/N print("最大",maxl,"最小",minl,"平均",ave)
''' 设置高考倒计时,每分钟更新状态 ''' import time from datetime import datetime gaokaotime = datetime(2019, 6, 7, 9, 0) now = datetime.now() timedelta = gaokaotime - now print(type(timedelta)) print("距离2019年高考还有:",timedelta.days, "天") while True: time.sleep(2) print("还有5分钟")
from statistics import mean, median import math import matplotlib.pyplot as plt import numpy as np import pandas as pd import random # Lp norm of two given data def distance(Class1, Class2, p): sum = 0 size_of_sttribute = len(Class1) #print("in dist(), # of attr:", size_of_sttribute) for i in range(siz...
class Node(object): def __init__(self, data=0): self.data = data self.next = None class LinkedList(object): """ A simple linked list """ def __init__(self): self.head = None def append(self, data): """Add a node at the end of the list with data""" if self.head =...
real = input("actual: PRESS ENTER ") code = input("coded: ") dict_alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] dict_alphabet2 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] def ...
## --------------------------------------------------------------------------------------- ## Name: Edweyza Rodriguez, Hyana Kang, Zephyr Wang ## Filename: let_me_retire.py ## Section: L04(Hyana), L01(Edweyza, Zephyr) ## Date: 04/28/2019 ## References: See README.txt ## ---------------------------...
score = 0 a = [ {"Skill 1" :{ "Name" : "Tackle", "Minimum level" : 1, "Damage" : 5, "Hit rate" : 0.3, }}, {"Skill 2" :{ "Name" : "Quick attack", "Minimum level" : 2, "Damage" : 3, "Hit rate": 0.5, }}, {"Skill 3" :{ "Name" : "Str...
a = { "name": "Vũ", "age": "15" } x = input("mục bạn muốn tìm ? ") if x in ["name", "age"]: print("True") else: print("False")
items = ["cầu lông", "LOL"] print(items) items.append("BTS") items.append("Death note") items.append("netflis") print(items) x = len(items) for i in range(x): print(items[i])
while True: x = input("cho số là ?") if x.isdigit(): if int(x) > 13: print("lớn hơn 13") break elif int(x) == 13: print(" bằng 13 ") break else: print("nhỏ hơn 13") break else: print("nhập lại số")
while True: x = input("cho tháng là ?") if x in [ "1" , "3" , "5" , "7" , "8" , "10" , "12" , "4" , "6" , "9" , "11" , "2" ]: if x in [ "1" , "3" , "5" , "7" , "8" , "10" , "12"]: print("có 31 ngày") break elif int(x) == 2: print("có 28 hoặc 29 ngày"...
while True: x = input("mật khẩu của bạn ?") check_x = 0 for i in x: if i.isdigit(): check_x = 1 if check_x == 1: if len(x) < 8: print("false") else: print("true") break
a = { "malli" : "Malli2010!", "nesh" : "1234", "sharon": "sharon2008" } z = input ("are you regestered yes(y) or no(n)") b = input("please input your username: ") c = input("please input your pasword: ") if z == "n": def regester(): s = input("pls input user name: ") h = input("pls input passwored: ...
compite = False; user = { "malli" : "Malli2010!", "nesh" : "1234", "sharon": "sharon2008" } while not compite: username = input("username") passwored = input("passwored") if username == user and passwored == passwored: continue elif username != user: print("This is not a valid usernam...
import json def malli(): asking = input("enter student name: ") with open ('person.txt','a') as file: print("you have entered: "+asking) b = input("do you want to add another person yes(y)no(n): ") file.write("\n") json.dump(asking,file) file.close() if b ...
class Node: def __init__(self,data,left=None,right=None): self.data=data self.left=left self.right=right #层次遍历 def lookup(self): queue = [self] l=[] while queue: current = queue.pop(0) l.append(current.data) if current.left...
# -*- coding: utf-8 -*- """ Created on Tue Mar 30 20:09:02 2021 @author: ansanchez """ import random import math def leer_numero(ini,fin,mensaje): while True: try: valor=int(input(mensaje)) except: print("wrong value") else: if valor >=...
import csv with open('geo-data.csv', mode='r') as infile: reader = csv.reader(infile) mydict = list(reader) zCode = input("Enter a zip code to lookup: ") for i in range(0,len(mydict)): if zCode == mydict[i][0]: print("Zipcode " + zCode + " belongs to " + mydict[i][3] + ", " ...
__author__ = 'ChrisP' print("Welcome to the catalog prep program!") print("This program will be used to correct the catalog spread sheets") print() provnum=0 provlist=list() while provnum < 3 or provnum >10: provnum=eval(input("How many Provinces are in this year's catalog? ")) if provnum < 3 or provnum > 10: ...
""" CP1404/CP5632 - Practical Capitalist Conrad wants a stock price simulator for a volatile stock. The price starts off at $10.00, and, at the end of every day there is a 50% chance it increases by 0 to 10%, and a 50% chance that it decreases by 0 to 5%. If the price rises above $1000, or falls below $0.01, the progra...
TITLE = "Electricity bill estimator" TARIFF_11 = 0.244618 TARIFF_31 = 0.136928 print(TITLE) price = float(input("Enter cents per kWh: ")) daily_use = float(input("Enter daily use in kWh: ")) number_of_days = float(input("Enter number of billing days: ")) estimated_bill = (price * daily_use * number_of_days) / 100 pr...
text = input("Text: ") words = text.split(" ") word_to_count = {} for word in words: if word in word_to_count: word_to_count[word] += 1 else: word_to_count[word] = 1 longest_word = "" for word in word_to_count: if len(word) > len(longest_word): longest_word = word for word in word_t...
'''a=int(input("enter a value")) if a>0: print("the given number is positive number") elif a==0: print("the value is zero") else: print("the given number is negative number") #check weather the given number even or odd n=int(input("enter a value")) if n%2==0: print("even") else: print("o...
import argparse def create_parser(): parser = argparse.ArgumentParser() parser.add_argument("-s", metavar = 'symbol', nargs = '?', help = "enter the symbol") parser.add_argument("-l", type = int, metavar='limit', nargs='?', help = "enter the number") parser.add_argument("-word", choices = ['left', 'right', 'downsid...
input = "974618352" moves = 10000000 def display_cups(cups): """A function to display the current position of cups ------------ cups: A list of integers representing the numbered cups ------------ :parameter cups: list """ print("Cups: ", e...
def readData(): data = [] fh = open("jolt_info.txt") for line in fh: data.append(int(line.strip())) return data def combineAdapters(data): jolt_differences = dict() jolt_differences["1"] = 0 jolt_differences["3"] = 0 data.sort() if data[0] == 1: jolt...
def populateGeography(): geography = [] fh = open("Geography.txt") for line in fh: geography.append(line.strip()) return geography tree_count = 0 bottom = False current_row = 0 current_coloumn = 0 geography = populateGeography() while bottom == False: current_coloumn+=3 ...
import re import math def read_data(): data = [] fh = open("directions.txt") for line in fh: data.append(line.strip()) return data def move(x,y,action,amount, waypoint_x, waypoint_y): if action == "N": waypoint_y-=amount elif action == "S": waypoint_y+=amo...
''' Is the string uppercase? Task Create a method is_uppercase() to see whether the string is ALL CAPS. For example: is_uppercase("c") == False is_uppercase("C") == True is_uppercase("hello I AM DONALD") == False is_uppercase("HELLO I AM DONALD") == True is_uppercase("ACSKLDFJSgSKLDFJSKLDFJ") == False is_uppercase("AC...
""" Задано чотирицифрове натуральне число. Знайти добуток цифр цього числа. Записати число в реверсному порядку. Посортувати цифри, що входять в дане число """ digit = input('please type four-digit natural number: ') print("Добуток цифр цього числа: ", int(digit[0])*int(digit[1])*int(digit[2])*int(digit[3])) list_of_d...
''' Given two ordered pairs calculate the distance between them. Round to two decimal places. This should be easy to do in 0(1) timing. ''' def distance(x1, y1, x2, y2): import math return round(math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2), 2) #############################################or################# ...
# # [53] Maximum Subarray # # https://leetcode.com/problems/maximum-subarray/description/ # # algorithms # Easy (40.30%) # Total Accepted: 301.7K # Total Submissions: 748.8K # Testcase Example: '[-2,1,-3,4,-1,2,1,-5,4]' # # # Find the contiguous subarray within an array (containing at least one number) # which has...
# # [416] Partition Equal Subset Sum # # https://leetcode.com/problems/partition-equal-subset-sum/description/ # # algorithms # Medium (38.84%) # Total Accepted: 41.4K # Total Submissions: 106.7K # Testcase Example: '[1,5,11,5]' # # Given a non-empty array containing only positive integers, find if the array # can ...
# # [301] Remove Invalid Parentheses # # https://leetcode.com/problems/remove-invalid-parentheses/description/ # # algorithms # Hard (35.84%) # Total Accepted: 66.9K # Total Submissions: 186.6K # Testcase Example: '"()())()"' # # # Remove the minimum number of invalid parentheses in order to make the input # strin...
# # [81] Search in Rotated Sorted Array II # # https://leetcode.com/problems/search-in-rotated-sorted-array-ii/description/ # # algorithms # Medium (32.70%) # Total Accepted: 118K # Total Submissions: 360.9K # Testcase Example: '[]\n5' # # # Follow up for "Search in Rotated Sorted Array": # What if duplicates are ...
# # [5] Longest Palindromic Substring # # https://leetcode.com/problems/longest-palindromic-substring/description/ # # algorithms # Medium (25.29%) # Total Accepted: 306.2K # Total Submissions: 1.2M # Testcase Example: '"babad"' # # Given a string s, find the longest palindromic substring in s. You may assume # tha...
# # [76] Minimum Window Substring # # https://leetcode.com/problems/minimum-window-substring/description/ # # algorithms # Hard (26.77%) # Total Accepted: 144.3K # Total Submissions: 538.9K # Testcase Example: '"ADOBECODEBANC"\n"ABC"' # # Given a string S and a string T, find the minimum window in S which will # co...
# # [37] Sudoku Solver # # https://leetcode.com/problems/sudoku-solver/description/ # # algorithms # Hard (32.09%) # Total Accepted: 91.1K # Total Submissions: 283.9K # Testcase Example: '[[".",".","9","7","4","8",".",".","."],["7",".",".",".",".",".",".",".","."],[".","2",".","1",".","9",".",".","."],[".",".","7",...
# # [10] Regular Expression Matching # # https://leetcode.com/problems/regular-expression-matching/description/ # # algorithms # Hard (24.34%) # Total Accepted: 193.6K # Total Submissions: 795.3K # Testcase Example: '"aa"\n"a"' # # Implement regular expression matching with support for '.' and '*'. # # # '.' Matc...
# # [414] Third Maximum Number # # https://leetcode.com/problems/third-maximum-number/description/ # # algorithms # Easy (28.09%) # Total Accepted: 58.4K # Total Submissions: 208K # Testcase Example: '[3,2,1]' # # Given a non-empty array of integers, return the third maximum number in this # array. If it does not e...
# # [190] Reverse Bits # # https://leetcode.com/problems/reverse-bits/description/ # # algorithms # Easy (29.37%) # Total Accepted: 131.4K # Total Submissions: 447.2K # Testcase Example: ' 0 (00000000000000000000000000000000)' # # Reverse bits of a given 32 bits unsigned integer. # # For example, given i...
# # [30] Substring with Concatenation of All Words # # https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/ # # algorithms # Hard (22.26%) # Total Accepted: 95.9K # Total Submissions: 430.9K # Testcase Example: '"barfoothefoobarman"\n["foo","bar"]' # # # You are given a string, s, a...
# # [128] Longest Consecutive Sequence # # https://leetcode.com/problems/longest-consecutive-sequence/description/ # # algorithms # Hard (38.25%) # Total Accepted: 138.1K # Total Submissions: 361K # Testcase Example: '[100,4,200,1,3,2]' # # # Given an unsorted array of integers, find the length of the longest # co...
# # [310] Minimum Height Trees # # https://leetcode.com/problems/minimum-height-trees/description/ # # algorithms # Medium (28.97%) # Total Accepted: 44.2K # Total Submissions: 152.5K # Testcase Example: '4\n[[1,0],[1,2],[1,3]]' # # # ⁠ For a undirected graph with tree characteristics, we can choose any node # a...