We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9380203 commit 9b1b3efCopy full SHA for 9b1b3ef
src/main/java/com/fishercoder/solutions/_21.java
@@ -6,10 +6,21 @@
6
* 21. Merge Two Sorted Lists
7
*
8
* Merge two sorted linked lists and return it as a new list.
9
- * The new list should be made by splicing together the nodes of the first two lists.*/
+ * The new list should be made by splicing together the nodes of the first two lists.
10
+ *
11
+ * Example:
12
+ * Input: 1->2->4, 1->3->4
13
+ * Output: 1->1->2->3->4->4
14
15
+ * */
16
17
public class _21 {
18
public static class Solution1 {
19
+ /**
20
+ * recursive solution
21
+ * Time: O(m+n)
22
+ * Space: O(m+n)
23
24
public ListNode mergeTwoLists(ListNode l1, ListNode l2) {
25
if (l1 == null) {
26
return l2;
0 commit comments