Skip to content

Commit 1afd821

Browse files
committed
✨ [q5/restruct]
1 parent df649c3 commit 1afd821

File tree

11 files changed

+114
-11
lines changed

11 files changed

+114
-11
lines changed

1/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
https://leetcode.com/problems/two-sum/
2+
3+
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
4+
5+
You may assume that each input would have exactly one solution, and you may not use the same element twice.
6+
7+
You can return the answer in any order.
8+
9+
10+
11+
Example 1:
12+
13+
Input: nums = [2,7,11,15], target = 9
14+
Output: [0,1]
15+
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
16+
Example 2:
17+
18+
Input: nums = [3,2,4], target = 6
19+
Output: [1,2]
20+
Example 3:
21+
22+
Input: nums = [3,3], target = 6
23+
Output: [0,1]
24+
25+
26+
Constraints:
27+
28+
2 <= nums.length <= 104
29+
-109 <= nums[i] <= 109
30+
-109 <= target <= 109
31+
Only one valid answer exists.
32+
33+
34+
Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?
File renamed without changes.
File renamed without changes.

2/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
https://leetcode.com/problems/add-two-numbers/
2+
3+
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
4+
5+
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
6+
7+
8+
9+
Example 1:
10+
11+
12+
Input: l1 = [2,4,3], l2 = [5,6,4]
13+
Output: [7,0,8]
14+
Explanation: 342 + 465 = 807.
15+
Example 2:
16+
17+
Input: l1 = [0], l2 = [0]
18+
Output: [0]
19+
Example 3:
20+
21+
Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
22+
Output: [8,9,9,9,0,0,0,1]
23+
24+
25+
Constraints:
26+
27+
The number of nodes in each linked list is in the range [1, 100].
28+
0 <= Node.val <= 9
29+
It is guaranteed that the list represents a number that does not have leading zeros.
File renamed without changes.
File renamed without changes.
File renamed without changes.

5/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
https://leetcode.com/problems/longest-palindromic-substring/
2+
3+
Given a string s, return the longest
4+
palindromic substring in s.
5+
6+
7+
Example 1:
8+
9+
Input: s = "babad"
10+
Output: "bab"
11+
Explanation: "aba" is also a valid answer.
12+
Example 2:
13+
14+
Input: s = "cbbd"
15+
Output: "bb"
16+
17+
18+
Constraints:
19+
20+
1 <= s.length <= 1000
21+
s consist of only digits and English letters.

5/solution.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} s
3+
* @return {string}
4+
*/
5+
const longestPalindrome = (s) => {
6+
console.log(`input: ${s}`)
7+
let P = [], center = 0, maxRight = 0;
8+
console.log(`P: ${P}, c: ${center}, right: ${maxRight}`)
9+
};
10+
11+
longestPalindrome("NBNNBR")

5_longest_palindromic_substring/solution.js

-7
This file was deleted.

README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
# How to run?
2-
Simply run iex `filename`.
1+
# Leetcode Solutions
32

4-
For example:
3+
1. [Two Sum](./1/)
4+
2. [Add Two Numbers](./2/)
5+
3. -
6+
4. -
7+
5. [Longest Palindromic Substring](./5/)
8+
9+
---
10+
## Run for JS
11+
```sh
12+
node ./.../solution.js
13+
```
14+
15+
---
16+
17+
## Run for Elixir
518
```sh
6-
iex ./leetcode_practices/q1_two_sum.ex
19+
iex ./.../solution.ex
720
```
21+
22+
---

0 commit comments

Comments
 (0)