Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47c0cfa

Browse files
committed
add: Two submissions
1 parent35ec129 commit47c0cfa

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

‎README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
| ID| Title| Solution| Difficulty|
44
|---| -----| --------| ----------|
5-
|1|[Two Sum](https://leetcode.com/problems/two-sum/)|[JavaScript](./src/two-sum.js)|Easy|
6-
|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/)|[JavaScript](./src/number-of-segments-in-a-string.js)|Easy|
5+
|1|[Two Sum](https://leetcode.com/problems/two-sum/)|[JavaScript](./src/two-sum/res.js)|Easy|
6+
|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers/)|[JavaScript](./src/add-two-numbers/res.js)|Medium|
7+
|181|[Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/)|[SQL](./src/employees-earning-more-than-their-managers/res.txt)|Easy|
8+
|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/)|[JavaScript](./src/number-of-segments-in-a-string/res.js)|Easy|

‎src/add-two-numbers/res.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Add Two Numbers
3+
*@authors Joe Jiang (hijiangtao@gmail.com)
4+
*@date 2017-02-15 20:52:23
5+
*
6+
* 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 contain a single digit. Add the two numbers and return it as a linked list.
7+
*
8+
* You may assume the two numbers do not contain any leading zero, except the number 0 itself.
9+
*
10+
* Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
11+
*
12+
* Output: 7 -> 0 -> 8
13+
*/
14+
15+
/**
16+
* Definition for singly-linked list.
17+
* function ListNode(val) {
18+
* this.val = val;
19+
* this.next = null;
20+
* }
21+
*/
22+
/**
23+
*@param {ListNode} l1
24+
*@param {ListNode} l2
25+
*@return {ListNode}
26+
*/
27+
letaddTwoNumbers=function(l1,l2){
28+
letcurrentAddVal=l1.val+l2.val,
29+
res=newListNode(currentAddVal%10),
30+
increment=currentAddVal>9 ?1:0;
31+
32+
if(l1.next!==null&&l2.next!==null){
33+
letnextl1=ListNode(l1.next.val+increment);
34+
nextl1.next=l1.next.next;
35+
res.next=newListNode(nextl1,l2.next)
36+
}elseif(l1.next===null){
37+
letnextl1=newListNode(increment);
38+
res.next=increment+addTwoNumbers(nextl1,l2.next)
39+
returnres
40+
}elseif(l2.next===null){
41+
letnextl2=newListNode(increment);
42+
res.next=addTwoNumbers(nextl2,l1.next)
43+
}elseif(increment){
44+
res.next=newListNode(increment);
45+
}
46+
47+
returnconvertToArray(res);
48+
};
49+
50+
letconvertToArray=function(LN){
51+
letres=[]
52+
for(;;){
53+
if(LN.next===null){
54+
returnres;
55+
}else{
56+
res.push(LN.val);
57+
LN=LN.next;
58+
}
59+
}
60+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Write your MySQL query statement below
2+
SELECT a.Name AS "Employee" FROM Employee a inner join Employee b ON a.ManagerId = b.Id AND a.Salary > b.Salary
File renamed without changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp