Skip to content

Updated readme #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 139 additions & 139 deletions README.md

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.github.javadev</groupId>
<artifactId>leetcode-in-all</artifactId>
<packaging>jar</packaging>
<version>1.8</version>
<version>1.10</version>
<name>leetcode-in-all</name>
<description>104 LeetCode algorithm problem solutions</description>
<url>https://github.com/javadev/LeetCode-in-All</url>
Expand Down Expand Up @@ -147,6 +147,36 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>generate-checksums</id>
<phase>verify</phase>
<configuration>
<target>
<checksum fileext=".md5" algorithm="MD5">
<fileset dir="${project.build.directory}">
<include name="*.jar"/>
<include name="*.pom"/>
</fileset>
</checksum>
<checksum fileext=".sha1" algorithm="SHA-1">
<fileset dir="${project.build.directory}">
<include name="*.jar"/>
<include name="*.pom"/>
</fileset>
</checksum>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions src/main/cpp/g0101_0200/s0142_linked_list_cycle_ii/Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
// #Data_Structure_II_Day_10_Linked_List #Level_1_Day_4_Linked_List #Udemy_Linked_List
// #Big_O_Time_O(N)_Space_O(1) #2024_05_27_Time_9_ms_(47.48%)_Space_10.2_MB_(18.65%)

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* detectCycle(ListNode* head) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/cpp/g0101_0200/s0148_sort_list/Solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
// #Divide_and_Conquer #Merge_Sort #Level_2_Day_4_Linked_List #Top_Interview_150_Divide_and_Conquer
// #Big_O_Time_O(log(N))_Space_O(log(N)) #2024_05_27_Time_130_ms_(50.49%)_Space_73.5_MB_(37.52%)

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* sortList(ListNode* head) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LeetCodeNet.G0001_0100.S0006_zigzag_conversion {

// #Medium #String #Top_Interview_150_Array/String
// #Medium #String #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(n)
// #2025_06_12_Time_3_ms_(95.39%)_Space_46.59_MB_(85.85%)

using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LeetCodeNet.G0001_0100.S0007_reverse_integer {

// #Medium #Top_Interview_Questions #Math #Udemy_Integers
// #Medium #Top_Interview_Questions #Math #Udemy_Integers #Big_O_Time_O(log10(x))_Space_O(1)
// #2025_06_12_Time_14_ms_(99.26%)_Space_29.02_MB_(67.56%)

public class Solution {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace LeetCodeNet.G0001_0100.S0008_string_to_integer_atoi {

// #Medium #Top_Interview_Questions #String #2025_06_12_Time_0_ms_(100.00%)_Space_41.82_MB_(46.21%)
// #Medium #Top_Interview_Questions #String #Big_O_Time_O(n)_Space_O(n)
// #2025_06_12_Time_0_ms_(100.00%)_Space_41.82_MB_(46.21%)

public class Solution {
public int MyAtoi(string str) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LeetCodeNet.G0001_0100.S0009_palindrome_number {

// #Easy #Math #Udemy_Integers #Top_Interview_150_Math
// #Easy #Math #Udemy_Integers #Top_Interview_150_Math #Big_O_Time_O(log10(x))_Space_O(1)
// #2025_06_12_Time_1_ms_(99.90%)_Space_34.74_MB_(67.61%)

public class Solution {
Expand Down
5 changes: 3 additions & 2 deletions src/main/csharp/g0401_0500/s0437_path_sum_iii/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace LeetCodeNet.G0401_0500.S0437_path_sum_iii {

// #Medium #Depth_First_Search #Tree #Binary_Tree #LeetCode_75_Binary_Tree/DFS #Level_2_Day_7_Tree
// #Big_O_Time_O(n)_Space_O(n) #2025_06_16_Time_10_ms_(66.33%)_Space_44.34_MB_(85.37%)
// #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree
// #LeetCode_75_Binary_Tree/DFS #Level_2_Day_7_Tree #Big_O_Time_O(n)_Space_O(n)
// #2025_06_16_Time_10_ms_(66.33%)_Space_44.34_MB_(85.37%)

using LeetCodeNet.Com_github_leetcode;

Expand Down
5 changes: 3 additions & 2 deletions src/main/csharp/g0701_0800/s0763_partition_labels/Solution.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace LeetCodeNet.G0701_0800.S0763_partition_labels {

// #Medium #String #Hash_Table #Greedy #Two_Pointers #Data_Structure_II_Day_7_String
// #Big_O_Time_O(n)_Space_O(1) #2025_06_16_Time_2_ms_(86.67%)_Space_46.51_MB_(87.11%)
// #Medium #Top_100_Liked_Questions #String #Hash_Table #Greedy #Two_Pointers
// #Data_Structure_II_Day_7_String #Big_O_Time_O(n)_Space_O(1)
// #2025_06_16_Time_2_ms_(86.67%)_Space_46.51_MB_(87.11%)

using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0006_zigzag_conversion;

// #Medium #String #Top_Interview_150_Array/String
// #Medium #String #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(n)
// #2024_11_17_Time_2_ms_(99.71%)_Space_44.5_MB_(94.69%)

public class Solution {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0007_reverse_integer;

// #Medium #Top_Interview_Questions #Math #Udemy_Integers
// #Medium #Top_Interview_Questions #Math #Udemy_Integers #Big_O_Time_O(log10(x))_Space_O(1)
// #2024_11_09_Time_0_ms_(100.00%)_Space_40.9_MB_(36.21%)

public class Solution {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package g0001_0100.s0008_string_to_integer_atoi;

// #Medium #Top_Interview_Questions #String #2024_11_09_Time_1_ms_(100.00%)_Space_42_MB_(95.40%)
// #Medium #Top_Interview_Questions #String #Big_O_Time_O(n)_Space_O(n)
// #2024_11_09_Time_1_ms_(100.00%)_Space_42_MB_(95.40%)

public class Solution {
public int myAtoi(String str) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0009_palindrome_number;

// #Easy #Math #Udemy_Integers #Top_Interview_150_Math
// #Easy #Math #Udemy_Integers #Top_Interview_150_Math #Big_O_Time_O(log10(x))_Space_O(1)
// #2024_11_09_Time_4_ms_(100.00%)_Space_44.1_MB_(28.20%)

public class Solution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,41 @@

// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Linked_List
// #Programming_Skills_II_Day_14 #Udemy_Linked_List #Top_Interview_150_Linked_List
// #Big_O_Time_O(N)_Space_O(N) #2024_11_13_Time_0_ms_(100.00%)_Space_44.1_MB_(92.12%)
// #Big_O_Time_O(N)_Space_O(N) #2025_07_04_Time_0_ms_(100.00%)_Space_43.96_MB_(99.29%)

import com_github_leetcode.random.Node;
import java.util.HashMap;
import java.util.Map;

/*
// Definition for a Node.
class Node {
public int val;
public Node next;
public Node random;
int val;
Node next;
Node random;

public Node() {}

public Node(int _val,Node _next,Node _random) {
val = _val;
next = _next;
random = _random;
public Node(int val) {
this.val = val;
this.next = null;
this.random = null;
}
};
}
*/
public class Solution {
public Node copyRandomList(Node head) {
if (head == null) {
return null;
}
// first pass to have a clone node point to the next node. ie A->B becomes A->clonedNode->B
Node curr = head;
while (curr != null) {
Node clonedNode = new Node(curr.val);
clonedNode.next = curr.next;
curr.next = clonedNode;
curr = clonedNode.next;
}
curr = head;
// second pass to make the cloned node's random pointer point to the orginal node's randome
// pointer.
// ie. A's random pointer becomes ClonedNode's random pointer
while (curr != null) {
if (curr.random != null) {
curr.next.random = curr.random.next;
} else {
curr.next.random = null;
}
curr = curr.next.next;
Map<Node, Node> hashMap = new HashMap<>();
Node cur = head;
while (cur != null) {
hashMap.put(cur, new Node(cur.val));
cur = cur.next;
}
curr = head;
// third pass to restore the links and return the head of the cloned nodes' list.
Node newHead = null;
while (curr != null) {
Node clonedNode;
if (newHead == null) {
clonedNode = curr.next;
newHead = clonedNode;
} else {
clonedNode = curr.next;
}
curr.next = clonedNode.next;
if (curr.next != null) {
clonedNode.next = curr.next.next;
} else {
clonedNode.next = null;
}
curr = curr.next;
cur = head;
while (cur != null) {
Node copy = hashMap.get(cur);
copy.next = hashMap.get(cur.next);
copy.random = hashMap.get(cur.random);
cur = cur.next;
}
return newHead;
return hashMap.get(head);
}
}
5 changes: 3 additions & 2 deletions src/main/java/g0401_0500/s0437_path_sum_iii/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package g0401_0500.s0437_path_sum_iii;

// #Medium #Depth_First_Search #Tree #Binary_Tree #LeetCode_75_Binary_Tree/DFS #Level_2_Day_7_Tree
// #Big_O_Time_O(n)_Space_O(n) #2024_11_17_Time_2_ms_(100.00%)_Space_44.7_MB_(11.66%)
// #Medium #Top_100_Liked_Questions #Depth_First_Search #Tree #Binary_Tree
// #LeetCode_75_Binary_Tree/DFS #Level_2_Day_7_Tree #Big_O_Time_O(n)_Space_O(n)
// #2024_11_17_Time_2_ms_(100.00%)_Space_44.7_MB_(11.66%)

import com_github_leetcode.TreeNode;
import java.util.HashMap;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/g0401_0500/s0494_target_sum/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
public class Solution {
public int findTargetSumWays(int[] nums, int target) {
int totalSum = 0;
int n = nums.length;
for (int i = 0; i < n; i++) {
totalSum += nums[i];
for (int num : nums) {
totalSum += num;
}
int sum = totalSum - target;
if (sum < 0 || sum % 2 == 1) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/g0701_0800/s0763_partition_labels/Solution.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package g0701_0800.s0763_partition_labels;

// #Medium #String #Hash_Table #Greedy #Two_Pointers #Data_Structure_II_Day_7_String
// #Big_O_Time_O(n)_Space_O(1) #2024_11_17_Time_2_ms_(100.00%)_Space_41.9_MB_(73.06%)
// #Medium #Top_100_Liked_Questions #String #Hash_Table #Greedy #Two_Pointers
// #Data_Structure_II_Day_7_String #Big_O_Time_O(n)_Space_O(1)
// #2024_11_17_Time_2_ms_(100.00%)_Space_41.9_MB_(73.06%)

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0006_zigzag_conversion

// #Medium #String #Top_Interview_150_Array/String
// #Medium #String #Top_Interview_150_Array/String #Big_O_Time_O(n)_Space_O(n)
// #2023_07_03_Time_200_ms_(97.79%)_Space_37.3_MB_(91.71%)

class Solution {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0007_reverse_integer

// #Medium #Top_Interview_Questions #Math #Udemy_Integers
// #Medium #Top_Interview_Questions #Math #Udemy_Integers #Big_O_Time_O(log10(x))_Space_O(1)
// #2023_07_03_Time_149_ms_(77.89%)_Space_33.5_MB_(84.42%)

class Solution {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package g0001_0100.s0008_string_to_integer_atoi

// #Medium #Top_Interview_Questions #String #2023_07_03_Time_172_ms_(82.90%)_Space_34.9_MB_(88.08%)
// #Medium #Top_Interview_Questions #String #Big_O_Time_O(n)_Space_O(n)
// #2023_07_03_Time_172_ms_(82.90%)_Space_34.9_MB_(88.08%)

class Solution {
fun myAtoi(str: String): Int {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package g0001_0100.s0009_palindrome_number

// #Easy #Math #Udemy_Integers #Top_Interview_150_Math
// #Easy #Math #Udemy_Integers #Top_Interview_150_Math #Big_O_Time_O(log10(x))_Space_O(1)
// #2023_07_03_Time_217_ms_(95.34%)_Space_36.1_MB_(98.21%)

class Solution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package g0101_0200.s0138_copy_list_with_random_pointer

// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Hash_Table #Linked_List
// #Programming_Skills_II_Day_14 #Udemy_Linked_List #Top_Interview_150_Linked_List
// #Big_O_Time_O(N)_Space_O(N) #2022_09_03_Time_274_ms_(80.58%)_Space_40.5_MB_(58.99%)
// #Big_O_Time_O(N)_Space_O(N) #2025_07_04_Time_123_ms_(90.70%)_Space_43.99_MB_(97.67%)

import com_github_leetcode.random.Node

Expand All @@ -18,48 +18,19 @@ import com_github_leetcode.random.Node
*/
class Solution {
fun copyRandomList(head: Node?): Node? {
if (head == null) {
return null
val hashMap: MutableMap<Node?, Node> = HashMap()
var cur = head
while (cur != null) {
hashMap.put(cur, Node(cur.`val`))
cur = cur.next
}
// first pass to have a clone node point to the next node. ie A->B becomes A->clonedNode->B
var curr: Node? = head
while (curr != null) {
val clonedNode = Node(curr.`val`)
clonedNode.next = curr.next
curr.next = clonedNode
curr = clonedNode.next
cur = head
while (cur != null) {
val copy: Node = hashMap[cur]!!
copy.next = hashMap[cur.next]
copy.random = hashMap[cur.random]
cur = cur.next
}
curr = head
// second pass to make the cloned node's random pointer point to the orginal node's randome
// pointer.
// ie. A's random pointer becomes ClonedNode's random pointer
while (curr != null) {
if (curr.random != null) {
curr.next?.random = curr.random!!.next
} else {
curr.next?.random = null
}
curr = curr.next?.next
}
curr = head
// third pass to restore the links and return the head of the cloned nodes' list.
var newHead: Node? = null
while (curr != null) {
var clonedNode: Node
if (newHead == null) {
clonedNode = curr.next!!
newHead = clonedNode
} else {
clonedNode = curr.next!!
}
curr.next = clonedNode.next
if (curr.next != null) {
clonedNode.next = curr.next!!.next
} else {
clonedNode.next = null
}
curr = curr.next
}
return newHead
return hashMap[head]
}
}
Loading