djdj - HTMLify profile

djdj's Profile Picture

djdj

471 Files

103458 Views

Latest files of /djdj/me/problems/leetcode

Q1148_Article_Views_I.sql djdj/me/problems/leetcode/Q1148_Article_Views_I.sql
381 Views
4 Comments
select distinct author_id as id from views
where author_id = viewer_id
order by id asc;

Q507_Perfect_Number.py djdj/me/problems/leetcode/Q507_Perfect_Number.py
333 Views
0 Comments
bool checkPerfectNumber(int num){
int i,s=0;
for(i=1;i<num/2+1;i++)
{
if(num%i==0){
s=s+i;
}
}
Q326_Power_of_Three.py djdj/me/problems/leetcode/Q326_Power_of_Three.py
307 Views
0 Comments
def isPowerOfTwo(self, n):
for i in range(0,31):
if n == 3**i:
return 1
return 0

Q2469_Convert_the_Temperature.py djdj/me/problems/leetcode/Q2469_Convert_the_Temperature.py
337 Views
0 Comments
def convertTemperature(self, celsius):
f = 1.8 * celsius + 32
k = celsius + 273.15
return [k,f]

Q1_Two_Sum.py djdj/me/problems/leetcode/Q1_Two_Sum.py
351 Views
0 Comments
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if ( nums[i] + nums[j] == target):
return [i, j]

Q175_Combine_Two_tables.sql djdj/me/problems/leetcode/Q175_Combine_Two_tables.sql
339 Views
0 Comments
select firstName, lastName, city, state from Person
LEFT join Address
on person.personId = address.personId;

Q504_Base_7.py djdj/me/problems/leetcode/Q504_Base_7.py
329 Views
0 Comments
def convertToBase7(self, num):
if num == 0:
return "0"
s = []
minus = False
if num < 0:
num = num * (-1)
minus = True
Q595_Big_Countries.sql djdj/me/problems/leetcode/Q595_Big_Countries.sql
351 Views
0 Comments
select name,population,area from World
where area >= 3000000 or population >= 25000000;

Q29_Divide_Two_Integers.py djdj/me/problems/leetcode/Q29_Divide_Two_Integers.py
342 Views
0 Comments
class Solution {
function divide($dividend, $divisor) {
if(intval($dividend/$divisor) > 2**31-1){
return intval(($dividend/$divisor)-1);
}
return intval($dividend/$divisor);
}
}
Q182_Duplicate_Emails.sql djdj/me/problems/leetcode/Q182_Duplicate_Emails.sql
369 Views
0 Comments
select email from person
group by email
having count(email) > 1;

Q50_Pow(x,n).py djdj/me/problems/leetcode/Q50_Pow(x,n).py
334 Views
0 Comments
def myPow(self, x, n):
return x ** n

Q1378_Replace_Employee_ID_With_The_Unique_Idendifier.sql djdj/me/problems/leetcode/Q1378_Replace_Employee_ID_With_The_Unique_Idendifier.sql
355 Views
0 Comments
select unique_id,name from Employees
left join EmployeeUNI
on Employees.id = EmployeeUNI.id;

Q43_Multiply_Strings.py djdj/me/problems/leetcode/Q43_Multiply_Strings.py
316 Views
0 Comments
def multiply(self, num1, num2):
num1 = int(num1)
num2 = int(num2)
a = num1 * num2
return str(a)

Q577_Employee_Bonus.sql djdj/me/problems/leetcode/Q577_Employee_Bonus.sql
345 Views
0 Comments
select name,bonus from employee
left join bonus
on bonus.empId = employee.empId
where bonus<1000 or bonus is null;

Q1683_Invalid_Tweets.sql djdj/me/problems/leetcode/Q1683_Invalid_Tweets.sql
338 Views
0 Comments
select tweet_id from tweets
where length(content) > 15;

Q476_Number_Complement.py djdj/me/problems/leetcode/Q476_Number_Complement.py
358 Views
0 Comments
def findComplement(self, num):
s = []
while num > 0: # 5
r = str(num % 2)#
s.append(r)
num = num // 2
s = s[::-1]
b = "".join(d for d in s)
Q231_Power_of_two.py djdj/me/problems/leetcode/Q231_Power_of_two.py
315 Views
0 Comments
def isPowerOfTwo(self, n):
for i in range(0,31):
if n == 2**i:
return 1
return 0

Q584_Find_Customer_Referee.sql djdj/me/problems/leetcode/Q584_Find_Customer_Referee.sql
347 Views
0 Comments
select name from Customer where referee_id is null or referee_id != 2;

Q69_Sqrt.php djdj/me/problems/leetcode/Q69_Sqrt.php
383 Views
0 Comments
function mySqrt($x) {
return intval(sqrt($x));
}

Q342_Power_of_Four.py djdj/me/problems/leetcode/Q342_Power_of_Four.py
360 Views
1 Comments
def isPowerOfTwo(self, n):
for i in range(0,31):
if n == 4**i:
return 1
return 0

Q69_Sqrt(x).c djdj/me/problems/leetcode/Q69_Sqrt(x).c
300 Views
0 Comments
Media file
Q176_Second_Highest_Salary.sql djdj/me/problems/leetcode/Q176_Second_Highest_Salary.sql
301 Views
0 Comments
select
(select distinct salary as SecondHighestSalary from Employee
order by salary desc limit 1,1) as SecondHighestSalary;

Q1009_Complement_of_Base_10_Integer.py djdj/me/problems/leetcode/Q1009_Complement_of_Base_10_Integer.py
331 Views
0 Comments
def bitwiseComplement(self, num):
if num==0:
return 1
s = []
while num > 0:
r = str(num % 2)
s.append(r)
num = num // 2
Q596_Classes_More_Than_5_Studeents.sql djdj/me/problems/leetcode/Q596_Classes_More_Than_5_Studeents.sql
305 Views
0 Comments
select class from courses
group by class
having count(class) >= 5

Q2652_Sum_Multiples.py djdj/me/problems/leetcode/Q2652_Sum_Multiples.py
310 Views
0 Comments
def sumOfMultiples(self,n):
s = 0
for i in range(1,n+1):
if i%3==0 or i%5==0 or i%7==0:
s = s + i
return s

Q367_Valid_Perfect_Square.c djdj/me/problems/leetcode/Q367_Valid_Perfect_Square.c
310 Views
0 Comments
Media file
Q7_Reverse_Integer.py djdj/me/problems/leetcode/Q7_Reverse_Integer.py
330 Views
0 Comments
def reverse(self, x):
if x > (2**30) or x < (-2**31)+1:
return 0
m = 0
if x < 0:
x = x * (-1)
m = 1
s = 0
Q9_Palidrome_Number.py djdj/me/problems/leetcode/Q9_Palidrome_Number.py
366 Views
0 Comments
class Solution(object):
def isPalindrome(self, x):
i = x
re = 0
"""
:type x: int
:rtype: bool
"""
Q2119_A_Number_After_a_Double.py djdj/me/problems/leetcode/Q2119_A_Number_After_a_Double.py
330 Views
0 Comments
def isSameAfterReversals(self, num):
t = num
s = 0
while num > 0: #526
r = num % 10 #6
s = s * 10 + r #6
num = num // 10 #52
s1 = 0
Q1068_Product_Sales_Analysis_I.sql djdj/me/problems/leetcode/Q1068_Product_Sales_Analysis_I.sql
348 Views
0 Comments
select product_name,year,price from sales
inner join product
on sales.product_id = product.product_id;

Q1757_Recyclable_and_Low_Fat_Products.sql djdj/me/problems/leetcode/Q1757_Recyclable_and_Low_Fat_Products.sql
395 Views
9 Comments
select product_id from Products
where low_fats = 'Y' and recyclable = 'Y'

Q2667_Create_Hello_World_Function.js djdj/me/problems/leetcode/Q2667_Create_Hello_World_Function.js
257 Views
0 Comments
var createHelloWorld = function() {

return function(...args) {
return "Hello World"
}
};

Q2620_Counter.js djdj/me/problems/leetcode/Q2620_Counter.js
223 Views
0 Comments
var createCounter = function(n) {
let c = n;
return function() {
return c++;
};
};

Q258_Add_Digits.rs djdj/me/problems/leetcode/Q258_Add_Digits.rs
339 Views
0 Comments
impl Solution {
pub fn add_digits(num: i32) -> i32 {
if(num==0){
return 0;
}
return (num-1)%9+1;
}
}
Q2703_Return_Length_of_Arguments_Passed.js djdj/me/problems/leetcode/Q2703_Return_Length_of_Arguments_Passed.js
250 Views
0 Comments
var argumentsLength = function(...args) {
return args.length;
};

Q1837_Sum_of_Digits_in_Base_K.py djdj/me/problems/leetcode/Q1837_Sum_of_Digits_in_Base_K.py
321 Views
0 Comments
class Solution(object):
def sumBase(self, n, k):
s=0
while n > 0:
r = n%k
s = s+r
n=n//k
return s
Q263_Ugly_Number.py djdj/me/problems/leetcode/Q263_Ugly_Number.py
359 Views
0 Comments
class Solution(object):
def isUgly(self, n):
if n == 1:
return 1
if n <=0:
return 0
for num in [2,3,5]:
while n % num == 0:
Q2427_Number_of_Common_Factors.rs djdj/me/problems/leetcode/Q2427_Number_of_Common_Factors.rs
336 Views
0 Comments
impl Solution {
pub fn common_factors(a: i32, b: i32) -> i32 {
let mut c=0;
for i in 1..a+b{
if(a%i==0 && b%i==0){
c=c+1;
}
}
Q2427_Number_of_Common_Factors.py djdj/me/problems/leetcode/Q2427_Number_of_Common_Factors.py
294 Views
0 Comments
class Solution(object):
def commonFactors(self, a, b):
c=0
for i in range(1,a+b):
if a%i==0 and b%i==0 :
c=c+1
return c

Q2235_Add_Two_Integers.cs djdj/me/problems/leetcode/Q2235_Add_Two_Integers.cs
339 Views
0 Comments
public class Solution {
public int Sum(int num1, int num2) {
return num1 + num2;
}
}

Q181_Employees_Earning_More_Than_Their_Managers.sql djdj/me/problems/leetcode/Q181_Employees_Earning_More_Than_Their_Managers.sql
324 Views
0 Comments
SELECT e.name AS Employee FROM Employee e, Employee a
WHERE e.managerID = a.id AND e.salary > a.salary;

Q509_Fibonacci_Series.c djdj/me/problems/leetcode/Q509_Fibonacci_Series.c
322 Views
0 Comments
Media file
Q1978_Employees_Whose_Manager_Left_the_Company.sql djdj/me/problems/leetcode/Q1978_Employees_Whose_Manager_Left_the_Company.sql
337 Views
0 Comments
SELECT employee_id FROM Employees
WHERE salary < 30000 and manager_id not in (SELECT employee_id FROM Employees)
ORDER BY(employee_id) ASC;

Q1667_Fix_Names_in_a_Table.sql djdj/me/problems/leetcode/Q1667_Fix_Names_in_a_Table.sql
327 Views
0 Comments
SELECT user_id, CONCAT(UPPER(LEFT(name,1)),LOWER(SUBSTRING(name,2))) AS name
FROM Users
ORDER BY user_id;

Q183_Customers_Who_Never_Order.sql djdj/me/problems/leetcode/Q183_Customers_Who_Never_Order.sql
293 Views
0 Comments
select name as Customers from Customers
where id not in(select customerId from Orders);

Q1050_Actor_and_Directors)Who_Cooperated_At_Least_Three_Times.sql djdj/me/problems/leetcode/Q1050_Actor_and_Directors)Who_Cooperated_At_Least_Three_Times.sql
327 Views
0 Comments
select actor_id,director_id from ActorDirector
group by actor_id, director_id
Having count(actor_id = director_id) >=3;