Skip to content

Commit

Permalink
refactor: change leetcode solutions path
Browse files Browse the repository at this point in the history
修改路径
  • Loading branch information
yanglbme committed Mar 17, 2020
1 parent 6ad1997 commit 39c225b
Show file tree
Hide file tree
Showing 2,772 changed files with 812 additions and 879 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums) {
sort(nums.begin(),nums.end());

vector<vector<int>> ans;

int sum;
int len = nums.size();
int left,right;
for(int i = 0; i< len;i++){
left = i + 1;
right = len - 1;
while(left < right){
sum = nums[i] + nums[left] + nums[right];
if(sum == 0){
vector<int> vec;
vec.push_back(nums[i]);
vec.push_back(nums[left]);
vec.push_back(nums[right]);
ans.push_back(vec);

while(left < right && nums[left] == nums[left + 1])left++;
while(left < right && nums[right] == nums[right - 1])right--;

left++;
right--;

}
if(sum > 0)right--;
if(sum < 0)left++;
}

while(i<len-1 && nums[i] == nums[i+1])i++;
}

return ans;

}
class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums) {
sort(nums.begin(),nums.end());

vector<vector<int>> ans;

int sum;
int len = nums.size();
int left,right;
for(int i = 0; i< len;i++){
left = i + 1;
right = len - 1;
while(left < right){
sum = nums[i] + nums[left] + nums[right];
if(sum == 0){
vector<int> vec;
vec.push_back(nums[i]);
vec.push_back(nums[left]);
vec.push_back(nums[right]);
ans.push_back(vec);

while(left < right && nums[left] == nums[left + 1])left++;
while(left < right && nums[right] == nums[right - 1])right--;

left++;
right--;

}
if(sum > 0)right--;
if(sum < 0)left++;
}

while(i<len-1 && nums[i] == nums[i+1])i++;
}

return ans;

}
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
if l1==nil {
return l2
}

if l2==nil {
return l1
}

var p *ListNode

if l1.Val > l2.Val {
p = l2
l2 = l2.Next
}else{
p = l1
l1 = l1.Next
}
var head *ListNode = p
p.Next = nil

for l1 != nil && l2 != nil {
if l1.Val > l2.Val {
p.Next = l2
l2 = l2.Next
}else{
p.Next = l1
l1 = l1.Next
}
p = p.Next
p.Next = nil
}

if l1 != nil{
p.Next = l1
}
if l2 != nil{
p.Next = l2
}

return head
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode {
if l1==nil {
return l2
}

if l2==nil {
return l1
}

var p *ListNode

if l1.Val > l2.Val {
p = l2
l2 = l2.Next
}else{
p = l1
l1 = l1.Next
}
var head *ListNode = p
p.Next = nil

for l1 != nil && l2 != nil {
if l1.Val > l2.Val {
p.Next = l2
l2 = l2.Next
}else{
p.Next = l1
l1 = l1.Next
}
p = p.Next
p.Next = nil
}

if l1 != nil{
p.Next = l1
}
if l2 != nil{
p.Next = l2
}

return head
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 39c225b

Please sign in to comment.