You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2 Add Two Numbers.js
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,9 @@
1
+
// You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
2
+
3
+
// Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
4
+
// Output: 7 -> 0 -> 8
5
+
6
+
1
7
/**
2
8
* Definition for singly-linked list.
3
9
* function ListNode(val) {
@@ -10,6 +16,11 @@
10
16
* @param {ListNode} l2
11
17
* @return {ListNode}
12
18
*/
19
+
20
+
21
+
22
+
// value reverse helps to asslign the first digit or both linklist
Copy file name to clipboardExpand all lines: 5 Longest Palindromic Substring.js
+58-5Lines changed: 58 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,34 @@
1
+
// Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
2
+
1
3
/**
2
4
* @param {string} s
3
5
* @return {string}
4
6
*/
5
7
8
+
9
+
6
10
varlongestPalindrome=function(s){
7
11
if(s===null||s.length===0){
8
12
return"";
9
13
}
10
14
11
15
varresult="";
16
+
17
+
// The reason to multiply by 2 is because
18
+
// Palindrome can be in two forms
19
+
// 1. abba There will be case which center has two idenitical charachter,
20
+
// And there will be maximum 2*n - 1 such case
21
+
// 2. aba There will be case which center has only one character
0 commit comments