Skip to content

Commit 66b09be

Browse files
authored
Added tasks 577, 585
1 parent f204721 commit 66b09be

File tree

7 files changed

+286
-55
lines changed

7 files changed

+286
-55
lines changed

README.md

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,9 +3393,11 @@ implementation 'com.github.javadev:leetcode-in-java:1.21'
33933393
| 0589 |[N-ary Tree Preorder Traversal](src.save/main/java/g0501_0600/s0589_n_ary_tree_preorder_traversal/Solution.java)| Easy | Depth_First_Search, Tree, Stack, Programming_Skills_I_Day_5_Function, Level_1_Day_6_Tree | 1 | 90.98
33943394
| 0587 |[Erect the Fence](src.save/main/java/g0501_0600/s0587_erect_the_fence/Solution.java)| Hard | Array, Math, Geometry | 12 | 90.91
33953395
| 0586 |[Customer Placing the Largest Number of Orders](src.save/main/java/g0501_0600/s0586_customer_placing_the_largest_number_of_orders/script.sql)| Easy | LeetCode_Curated_SQL_70, Database, SQL_I_Day_8_Function | 484 | 66.42
3396+
| 0585 |[Investments in 2016](src/main/java/g0501_0600/s0585_investments_in_2016/script.sql)| Medium | Database | 729 | 99.22
33963397
| 0584 |[Find Customer Referee](src.save/main/java/g0501_0600/s0584_find_customer_referee/script.sql)| Easy | Database, SQL_I_Day_1_Select | 531 | 58.63
33973398
| 0583 |[Delete Operation for Two Strings](src.save/main/java/g0501_0600/s0583_delete_operation_for_two_strings/Solution.java)| Medium | String, Dynamic_Programming, Algorithm_II_Day_17_Dynamic_Programming | 12 | 79.10
33983399
| 0581 |[Shortest Unsorted Continuous Subarray](src.save/main/java/g0501_0600/s0581_shortest_unsorted_continuous_subarray/Solution.java)| Medium | Array, Sorting, Greedy, Two_Pointers, Stack, Monotonic_Stack | 2 | 84.72
3400+
| 0577 |[Employee Bonus](src/main/java/g0501_0600/s0577_employee_bonus/script.sql)| Easy | Database | 1473 | 95.83
33993401
| 0576 |[Out of Boundary Paths](src.save/main/java/g0501_0600/s0576_out_of_boundary_paths/Solution.java)| Medium | Dynamic_Programming | 5 | 92.95
34003402
| 0575 |[Distribute Candies](src.save/main/java/g0501_0600/s0575_distribute_candies/Solution.java)| Easy | Array, Hash_Table | 67 | 42.81
34013403
| 0572 |[Subtree of Another Tree](src.save/main/java/g0501_0600/s0572_subtree_of_another_tree/Solution.java)| Easy | Depth_First_Search, Tree, Binary_Tree, Hash_Function, String_Matching, Algorithm_II_Day_7_Breadth_First_Search_Depth_First_Search | 1 | 100.00
@@ -3821,58 +3823,4 @@ implementation 'com.github.javadev:leetcode-in-java:1.21'
38213823
| 0047 |[Permutations II](src.save/main/java/g0001_0100/s0047_permutations_ii/Solution.java)| Medium | Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking | 2 | 93.29
38223824
| 0046 |[Permutations](src.save/main/java/g0001_0100/s0046_permutations/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Backtracking, Algorithm_I_Day_11_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion | 1 | 97.24
38233825
| 0045 |[Jump Game II](src.save/main/java/g0001_0100/s0045_jump_game_ii/Solution.java)| Medium | Top_100_Liked_Questions, Array, Dynamic_Programming, Greedy, Algorithm_II_Day_13_Dynamic_Programming, Dynamic_Programming_I_Day_4 | 2 | 75.75
3824-
| 0044 |[Wildcard Matching](src.save/main/java/g0001_0100/s0044_wildcard_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion, Udemy_Dynamic_Programming | 4 | 90.87
3825-
| 0043 |[Multiply Strings](src.save/main/java/g0001_0100/s0043_multiply_strings/Solution.java)| Medium | String, Math, Simulation, Data_Structure_II_Day_8_String, Programming_Skills_II_Day_4, Level_2_Day_2_String | 2 | 99.84
3826-
| 0042 |[Trapping Rain Water](src.save/main/java/g0001_0100/s0042_trapping_rain_water/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Two_Pointers, Stack, Monotonic_Stack, Dynamic_Programming_I_Day_9, Udemy_Two_Pointers | 1 | 98.06
3827-
| 0041 |[First Missing Positive](src.save/main/java/g0001_0100/s0041_first_missing_positive/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Udemy_Arrays | 5 | 50.34
3828-
| 0040 |[Combination Sum II](src.save/main/java/g0001_0100/s0040_combination_sum_ii/Solution.java)| Medium | Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking | 4 | 86.03
3829-
| 0039 |[Combination Sum](src.save/main/java/g0001_0100/s0039_combination_sum/Solution.java)| Medium | Top_100_Liked_Questions, Array, Backtracking, Algorithm_II_Day_10_Recursion_Backtracking, Level_2_Day_20_Brute_Force/Backtracking, Udemy_Backtracking/Recursion | 3 | 92.97
3830-
| 0038 |[Count and Say](src.save/main/java/g0001_0100/s0038_count_and_say/Solution.java)| Medium | Top_Interview_Questions, String | 2 | 99.52
3831-
| 0037 |[Sudoku Solver](src.save/main/java/g0001_0100/s0037_sudoku_solver/Solution.java)| Hard | Array, Matrix, Backtracking | 3 | 98.89
3832-
| 0036 |[Valid Sudoku](src.save/main/java/g0001_0100/s0036_valid_sudoku/Solution.java)| Medium | Top_Interview_Questions, Array, Hash_Table, Matrix, Data_Structure_I_Day_5_Array | 2 | 95.85
3833-
| 0035 |[Search Insert Position](src.save/main/java/g0001_0100/s0035_search_insert_position/Solution.java)| Easy | Top_100_Liked_Questions, Array, Binary_Search, Algorithm_I_Day_1_Binary_Search, Binary_Search_I_Day_2 | 0 | 100.00
3834-
| 0034 |[Find First and Last Position of Element in Sorted Array](src.save/main/java/g0001_0100/s0034_find_first_and_last_position_of_element_in_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_5 | 0 | 100.00
3835-
| 0033 |[Search in Rotated Sorted Array](src.save/main/java/g0001_0100/s0033_search_in_rotated_sorted_array/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Algorithm_II_Day_1_Binary_Search, Binary_Search_I_Day_11, Level_2_Day_8_Binary_Search, Udemy_Binary_Search | 0 | 100.00
3836-
| 0032 |[Longest Valid Parentheses](src.save/main/java/g0001_0100/s0032_longest_valid_parentheses/Solution.java)| Hard | Top_100_Liked_Questions, String, Dynamic_Programming, Stack | 2 | 93.91
3837-
| 0031 |[Next Permutation](src.save/main/java/g0001_0100/s0031_next_permutation/Solution.java)| Medium | Top_100_Liked_Questions, Array, Two_Pointers | 1 | 85.59
3838-
| 0030 |[Substring with Concatenation of All Words](src.save/main/java/g0001_0100/s0030_substring_with_concatenation_of_all_words/Solution.java)| Hard | String, Hash_Table, Sliding_Window | 9 | 97.68
3839-
| 0029 |[Divide Two Integers](src.save/main/java/g0001_0100/s0029_divide_two_integers/Solution.java)| Medium | Top_Interview_Questions, Math, Bit_Manipulation, Udemy_Bit_Manipulation | 1 | 99.96
3840-
| 0028 |[Implement strStr()](src.save/main/java/g0001_0100/s0028_implement_strstr/Solution.java)| Easy | Top_Interview_Questions, String, Two_Pointers, String_Matching, Programming_Skills_II_Day_1 | 0 | 100.00
3841-
| 0027 |[Remove Element](src.save/main/java/g0001_0100/s0027_remove_element/Solution.java)| Easy | Array, Two_Pointers | 0 | 100.00
3842-
| 0026 |[Remove Duplicates from Sorted Array](src.save/main/java/g0001_0100/s0026_remove_duplicates_from_sorted_array/Solution.java)| Easy | Top_Interview_Questions, Array, Two_Pointers, Udemy_Two_Pointers | 1 | 99.47
3843-
| 0025 |[Reverse Nodes in k-Group](src.save/main/java/g0001_0100/s0025_reverse_nodes_in_k_group/Solution.java)| Hard | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_13_Linked_List, Udemy_Linked_List | 0 | 100.00
3844-
| 0024 |[Swap Nodes in Pairs](src.save/main/java/g0001_0100/s0024_swap_nodes_in_pairs/Solution.java)| Medium | Top_100_Liked_Questions, Linked_List, Recursion, Data_Structure_II_Day_12_Linked_List, Udemy_Linked_List | 0 | 100.00
3845-
| 0023 |[Merge k Sorted Lists](src.save/main/java/g0001_0100/s0023_merge_k_sorted_lists/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Heap_Priority_Queue, Linked_List, Divide_and_Conquer, Merge_Sort | 2 | 97.31
3846-
| 0022 |[Generate Parentheses](src.save/main/java/g0001_0100/s0022_generate_parentheses/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion | 2 | 63.16
3847-
| 0021 |[Merge Two Sorted Lists](src.save/main/java/g0001_0100/s0021_merge_two_sorted_lists/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Data_Structure_I_Day_7_Linked_List, Algorithm_I_Day_10_Recursion_Backtracking, Level_1_Day_3_Linked_List, Udemy_Linked_List | 1 | 69.17
3848-
| 0020 |[Valid Parentheses](src.save/main/java/g0001_0100/s0020_valid_parentheses/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, String, Stack, Data_Structure_I_Day_9_Stack_Queue, Udemy_Strings | 3 | 51.72
3849-
| 0019 |[Remove Nth Node From End of List](src.save/main/java/g0001_0100/s0019_remove_nth_node_from_end_of_list/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Two_Pointers, Linked_List, Algorithm_I_Day_5_Two_Pointers, Level_2_Day_3_Linked_List | 1 | 59.72
3850-
| 0018 |[4Sum](src.save/main/java/g0001_0100/s0018_4sum/Solution.java)| Medium | Array, Sorting, Two_Pointers | 3 | 99.47
3851-
| 0017 |[Letter Combinations of a Phone Number](src.save/main/java/g0001_0100/s0017_letter_combinations_of_a_phone_number/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Backtracking, Algorithm_II_Day_11_Recursion_Backtracking, Udemy_Backtracking/Recursion | 0 | 100.00
3852-
| 0016 |[3Sum Closest](src.save/main/java/g0001_0100/s0016_3sum_closest/Solution.java)| Medium | Array, Sorting, Two_Pointers, Level_2_Day_14_Sliding_Window/Two_Pointer | 3 | 99.98
3853-
| 0015 |[3Sum](src.save/main/java/g0001_0100/s0015_3sum/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Sorting, Two_Pointers, Data_Structure_II_Day_1_Array, Algorithm_II_Day_3_Two_Pointers, Udemy_Two_Pointers | 28 | 71.04
3854-
| 0014 |[Longest Common Prefix](src.save/main/java/g0001_0100/s0014_longest_common_prefix/Solution.java)| Easy | Top_Interview_Questions, String, Level_2_Day_2_String, Udemy_Strings | 1 | 84.75
3855-
| 0013 |[Roman to Integer](src.save/main/java/g0001_0100/s0013_roman_to_integer/Solution.java)| Easy | Top_Interview_Questions, String, Hash_Table, Math | 6 | 79.00
3856-
| 0012 |[Integer to Roman](src.save/main/java/g0001_0100/s0012_integer_to_roman/Solution.java)| Medium | String, Hash_Table, Math | 7 | 75.71
3857-
| 0011 |[Container With Most Water](src.save/main/java/g0001_0100/s0011_container_with_most_water/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Greedy, Two_Pointers, Algorithm_II_Day_4_Two_Pointers | 2 | 99.81
3858-
| 0010 |[Regular Expression Matching](src.save/main/java/g0001_0100/s0010_regular_expression_matching/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Recursion, Udemy_Dynamic_Programming | 3 | 80.22
3859-
| 0009 |[Palindrome Number](src.save/main/java/g0001_0100/s0009_palindrome_number/Solution.java)| Easy | Math, Udemy_Integers | 13 | 58.99
3860-
| 0008 |[String to Integer (atoi)](src.save/main/java/g0001_0100/s0008_string_to_integer_atoi/Solution.java)| Medium | Top_Interview_Questions, String | 3 | 57.89
3861-
| 0007 |[Reverse Integer](src.save/main/java/g0001_0100/s0007_reverse_integer/Solution.java)| Medium | Top_Interview_Questions, Math, Udemy_Integers | 2 | 66.74
3862-
| 0006 |[Zigzag Conversion](src.save/main/java/g0001_0100/s0006_zigzag_conversion/Solution.java)| Medium | String | 3 | 98.64
3863-
| 0005 |[Longest Palindromic Substring](src.save/main/java/g0001_0100/s0005_longest_palindromic_substring/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Dynamic_Programming, Data_Structure_II_Day_9_String, Algorithm_II_Day_14_Dynamic_Programming, Dynamic_Programming_I_Day_17, Udemy_Strings | 10 | 98.57
3864-
| 0004 |[Median of Two Sorted Arrays](src.save/main/java/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.java)| Hard | Top_100_Liked_Questions, Top_Interview_Questions, Array, Binary_Search, Divide_and_Conquer | 3 | 81.72
3865-
| 0003 |[Longest Substring Without Repeating Characters](src.save/main/java/g0001_0100/s0003_longest_substring_without_repeating_characters/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, String, Hash_Table, Sliding_Window, Algorithm_I_Day_6_Sliding_Window, Level_2_Day_14_Sliding_Window/Two_Pointer, Udemy_Strings | 5 | 91.03
3866-
| 0002 |[Add Two Numbers](src.save/main/java/g0001_0100/s0002_add_two_numbers/Solution.java)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Math, Linked_List, Recursion, Data_Structure_II_Day_10_Linked_List, Programming_Skills_II_Day_15 | 2 | 98.23
3867-
| 0001 |[Two Sum](src.save/main/java/g0001_0100/s0001_two_sum/Solution.java)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Data_Structure_I_Day_2_Array, Level_1_Day_13_Hashmap, Udemy_Arrays | 4 | 69.91
3868-
3869-
## Contributing
3870-
Your ideas/fixes/algorithms are more than welcome!
3871-
3872-
1. Fork this repo
3873-
2. Clone your forked repo (`git clone https://github.com/YOUR_GITHUB_USERNAME/LeetCode-in-Java.git`) onto your local machine
3874-
3. `cd` into your cloned directory, create your feature branch (`git checkout -b my-awesome-fix`)
3875-
4. `git add` your desired changes to this repo
3876-
5. Commit your changes (`git commit -m 'Added some awesome features/fixes'`)
3877-
6. Push to the branch (`git push origin my-awesome-feature`)
3878-
7. Open your forked repo on Github website, create a new Pull Request to this repo!
3826+
| 0044 |[Wildcard Matching](src.save/main/java/g0001_0100/s0044_wildcard_matching/Solution.java)| Hard | Top_Interview_Questions, String, Dynamic_Programming, Greedy, Recursion, Udemy_Dynamic_Programming | 4 |
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
577\. Employee Bonus
2+
3+
Easy
4+
5+
SQL Schema
6+
7+
Table: `Employee`
8+
9+
+-------------+---------+
10+
| Column Name | Type |
11+
+-------------+---------+
12+
| empId | int |
13+
| name | varchar |
14+
| supervisor | int |
15+
| salary | int |
16+
+-------------+---------+
17+
18+
empId is the primary key column for this table.
19+
20+
Each row of this table indicates the name and the ID of an employee in addition to their salary and the id of their manager.
21+
22+
Table: `Bonus`
23+
24+
+-------------+------+
25+
| Column Name | Type |
26+
+-------------+------+
27+
| empId | int |
28+
| bonus | int |
29+
+-------------+------+
30+
31+
empId is the primary key column for this table.
32+
33+
empId is a foreign key to empId from the Employee table.
34+
35+
Each row of this table contains the id of an employee and their respective bonus.
36+
37+
Write an SQL query to report the name and bonus amount of each employee with a bonus **less than** `1000`.
38+
39+
Return the result table in **any order**.
40+
41+
The query result format is in the following example.
42+
43+
**Example 1:**
44+
45+
**Input:**
46+
47+
Employee table:
48+
49+
+-------+--------+------------+--------+
50+
| empId | name | supervisor | salary |
51+
+-------+--------+------------+--------+
52+
| 3 | Brad | null | 4000 |
53+
| 1 | John | 3 | 1000 |
54+
| 2 | Dan | 3 | 2000 |
55+
| 4 | Thomas | 3 | 4000 |
56+
+-------+--------+------------+--------+
57+
58+
Bonus table:
59+
60+
+-------+-------+
61+
| empId | bonus |
62+
+-------+-------+
63+
| 2 | 500 |
64+
| 4 | 2000 |
65+
+-------+-------+
66+
67+
**Output:**
68+
69+
+------+-------+
70+
| name | bonus |
71+
+------+-------+
72+
| Brad | null |
73+
| John | null |
74+
| Dan | 500 |
75+
+------+-------+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Write your MySQL query statement below
2+
# #Easy #Database #2023_05_18_Time_1473_ms_(95.83%)_Space_0B_(100.00%)
3+
SELECT name, bonus
4+
FROM Employee e
5+
LEFT JOIN Bonus b ON e.empId = b.empId
6+
WHERE bonus < 1000 or b.empId is null;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
585\. Investments in 2016
2+
3+
Medium
4+
5+
SQL Schema
6+
7+
Table: `Insurance`
8+
9+
+-------------+-------+
10+
| Column Name | Type |
11+
+-------------+-------+
12+
| pid | int |
13+
| tiv_2015 | float |
14+
| tiv_2016 | float |
15+
| lat | float |
16+
| lon | float |
17+
+-------------+-------+
18+
19+
pid is the primary key column for this table.
20+
21+
Each row of this table contains information about one policy where:
22+
23+
pid is the policyholder's policy ID.
24+
25+
tiv\_2015 is the total investment value in 2015 and tiv\_2016 is the total investment value in 2016.
26+
27+
lat is the latitude of the policy holder's city. It's guaranteed that lat is not NULL.
28+
29+
lon is the longitude of the policy holder's city. It's guaranteed that lon is not NULL.
30+
31+
Write an SQL query to report the sum of all total investment values in 2016 `tiv_2016`, for all policyholders who:
32+
33+
* have the same `tiv_2015` value as one or more other policyholders, and
34+
* are not located in the same city like any other policyholder (i.e., the (`lat, lon`) attribute pairs must be unique).
35+
36+
Round `tiv_2016` to **two decimal places**.
37+
38+
The query result format is in the following example.
39+
40+
**Example 1:**
41+
42+
**Input:** Insurance table:
43+
44+
+-----+----------+----------+-----+-----+
45+
| pid | tiv_2015 | tiv_2016 | lat | lon |
46+
+-----+----------+----------+-----+-----+
47+
| 1 | 10 | 5 | 10 | 10 |
48+
| 2 | 20 | 20 | 20 | 20 |
49+
| 3 | 10 | 30 | 20 | 20 |
50+
| 4 | 10 | 40 | 40 | 40 |
51+
+-----+----------+----------+-----+-----+
52+
53+
**Output:**
54+
55+
+----------+
56+
| tiv_2016 |
57+
+----------+
58+
| 45.00 |
59+
+----------+
60+
61+
**Explanation:**
62+
63+
The first record in the table, like the last record, meets both of the two criteria.
64+
The tiv\_2015 value 10 is the same as the third and fourth records, and its location is unique.
65+
66+
The second record does not meet any of the two criteria. Its tiv\_2015 is not like any other policyholders and its location is the same as the third record, which makes the third record fail, too.
67+
So, the result is the sum of tiv\_2016 of the first and last record, which is 45.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Write your MySQL query statement below
2+
# #Medium #Database #2023_05_18_Time_729_ms_(99.22%)_Space_0B_(100.00%)
3+
select round(sum(tiv_2016),2) tiv_2016 from insurance i1
4+
where tiv_2015 in (select tiv_2015 from insurance i2
5+
where i1.pid != i2.pid)
6+
and (lat, lon) not in (select lat, lon from insurance i3
7+
where i3.pid != i1.pid)

0 commit comments

Comments
 (0)