Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #279

Open
wants to merge 293 commits into
base: master
Choose a base branch
from
Open

merge #279

Changes from 2 commits
Commits
Show all changes
293 commits
Select commit Hold shift + click to select a range
5c5363e
fix typo caused build error
xusiwei Feb 25, 2016
d544ca4
Merge pull request #97 from xusiwei/master
haoel Feb 27, 2016
4555282
Merge pull request #95 from wilsoncao/master
haoel Feb 27, 2016
0f33a8d
C solution for "Reverse Words in a String", in O(1) space
xusiwei Feb 27, 2016
be582a0
added increasingTripletSubsequence
Vally79 Feb 27, 2016
2d9734d
Merge pull request #99 from Vally79/master
Vally79 Feb 27, 2016
4c6d32f
Merge pull request #98 from xusiwei/master
haoel Feb 29, 2016
e8e1847
refine the comments
haoel Feb 29, 2016
23801d8
fix #96
haoel Feb 29, 2016
da6bc7c
New Problem "Patching Array"
haoel Feb 29, 2016
3dfaf04
union-find solution for "Surrounded Regions",
xusiwei Mar 12, 2016
38f46e5
added houseRobberIII
Vally79 Apr 29, 2016
968679b
Merge pull request #106 from Vally79/master
Vally79 Apr 29, 2016
d88cc15
added reverseVowelsOfAString
Vally79 Apr 30, 2016
354fa7e
Merge pull request #107 from Vally79/master
Vally79 Apr 30, 2016
a127523
added topKFrequentElements
Vally79 May 2, 2016
62fc7b7
Merge pull request #108 from Vally79/master
Vally79 May 2, 2016
43156ff
added intersectionOfTwoArrays
Vally79 May 20, 2016
f6b0305
Merge pull request #109 from Vally79/master
Vally79 May 20, 2016
7d3ec84
fixed typo
Vally79 May 20, 2016
3dd9e69
Merge pull request #110 from Vally79/master
Vally79 May 20, 2016
96f799f
added intersectionOfTwoArraysII
Vally79 May 22, 2016
c38062d
Merge pull request #111 from Vally79/master
Vally79 May 22, 2016
cf12236
the solution of the problem "Reverse String"
haoel May 29, 2016
32ce962
make the script can detect the author name automatically
haoel May 29, 2016
13eef8d
the solution of problem "Power of Four"
haoel May 29, 2016
35ed8b3
the solution of problem "Integer Break"
haoel May 29, 2016
ecb1789
the solution of the problem "Flatten Nested List Iterator"
haoel May 29, 2016
eb040df
the solution of the problem "Counting Bits"
haoel May 29, 2016
94e9e4b
fix a wrong number in comment
wuxun Jun 14, 2016
0de9d91
Merge pull request #112 from wuxun/master
haoel Jun 21, 2016
b4e0836
Update bullsAndCows.cpp
tvytlx Jul 6, 2016
8168f4b
Merge pull request #116 from arctanx0/master
haoel Aug 7, 2016
227b574
added combinationSumIV
Vally79 Aug 7, 2016
0872617
Merge pull request #117 from Vally79/master
Vally79 Aug 7, 2016
931ba6a
added wiggleSubsequence
Vally79 Aug 8, 2016
ec9b5ac
Merge pull request #118 from Vally79/master
Vally79 Aug 8, 2016
ec8013d
modified: cpp/intersectionOfTwoArrays/intersectionOfTwoArrays.cpp
Aug 11, 2016
0c322fe
Merge pull request #119 from FEIGONG/master
haoel Aug 23, 2016
5e14762
New Problem "Lexicographical Numbers"
haoel Aug 23, 2016
5fe30bc
New Problem "First Unique Character in a String"
haoel Aug 23, 2016
25633c1
add indent
haoel Aug 23, 2016
f9dc634
New Problem "Longest Absolute File Path"
haoel Aug 23, 2016
bfeb664
typo
haoel Aug 23, 2016
729eec6
uncomment the code
haoel Aug 24, 2016
d076c2c
New Problem Solution - "Mini Parser"
haoel Aug 24, 2016
d666cbf
New Problem Solution - "Shuffle an Array"
haoel Aug 24, 2016
6906cda
New Problem Solution - "Ransom Note"
haoel Aug 24, 2016
9def962
New Problem Solution - "Linked List Random Node"
haoel Aug 24, 2016
2c9f3c2
Two Problems Solutions - "Insert Delete GetRandom O(1)"
haoel Aug 25, 2016
4eb4806
modified: algorithms/cpp/maximumDepthOfBinaryTree/maximumDepthOfBi…
Aug 31, 2016
7f16adf
add readme.sh script to help to generate the content in README.md for…
haoel Sep 7, 2016
1714519
New Problem Solution - "Find the Difference"
haoel Sep 7, 2016
a4b191a
New Problem Solution "Elimination Game"
haoel Sep 7, 2016
626efee
New Problem Solution "Perfect Rectangle"
haoel Sep 7, 2016
ea1a213
New Problem "Is Subsequence"
haoel Sep 7, 2016
cfe8809
New Problem Solution "UTF-8 Validation"
haoel Sep 7, 2016
2f3a77d
New Problem Solution"Longest Substring with At Least K Repeating Char…
haoel Sep 7, 2016
032602d
Merge pull request #122 from FEIGONG/master
haoel Oct 10, 2016
5353d9e
Merge pull request #101 from xusiwei/master
haoel Oct 10, 2016
2d433dd
correct the URL of "Elimination Game"
haoel Nov 2, 2016
421189e
New Problem Solution "Rotate Function"
haoel Nov 2, 2016
6becbec
New Problem Solution "Integer Replacement"
haoel Nov 4, 2016
51a0624
New Problem Solution "Random Pick Index"
haoel Nov 4, 2016
f9e16a7
New Problem Solution "Evaluate Division"
haoel Nov 4, 2016
fa4d3f6
New Problem Solution "Nth Digit"
haoel Nov 5, 2016
4285701
New Problem Solution "Binary Watch"
haoel Nov 5, 2016
fff0041
make the variables name more sense
haoel Nov 5, 2016
a991e74
New Problem Solution - "Remove K Digits"
haoel Nov 11, 2016
24839ce
New Problem Solution "Sum of Left Leaves"
haoel Nov 11, 2016
51e3e7f
fix: change the direcotry
haoel Nov 11, 2016
7961704
New Problem Solution "Convert a Number to Hexadecimal"
haoel Nov 11, 2016
0e3f0e2
New Problem Solution "Frog Jump"
haoel Nov 12, 2016
7fb99ce
New Problem Solution "Queue Reconstruction by Height"
haoel Nov 12, 2016
9f00ad1
New Problem Solution "Add Strings"
haoel Nov 12, 2016
c54086b
adjust the file's directory
haoel Nov 12, 2016
e7e1252
New Problem "Arithmetic Slices"
haoel Nov 13, 2016
48978d8
New Problem Solution "Fizz Buzz"
haoel Nov 13, 2016
4d68a13
New Problem Solution "Longest Palindrome"
haoel Nov 13, 2016
0941073
New Problem Soluiton "Split Array Largest Sum"
haoel Nov 13, 2016
f9a8a8b
New Problem Solution "Sentence Screen Fitting"
yiakwy Nov 28, 2016
a3dd93d
add heart
yiakwy Nov 28, 2016
8d833c1
New method (non recursive) for CourseSchedule
yiakwy Nov 28, 2016
879e9e6
array index out of bounds, fix to low<n-1
omengye Dec 26, 2016
b0507b1
Merge pull request #128 from omengye/patch-1
haoel Jan 2, 2017
1a3bf58
New Problem Solution - "Super Ugly Number"
haoel Jan 2, 2017
aed69e7
fix: forgot commit the "Find the Difference"
haoel Jan 2, 2017
9c3eac7
New Problem Solution "Remove Duplicate Letters"
haoel Jan 2, 2017
f3c62b3
New Problem Solution - "Maximum Product of Word Lengths"
haoel Jan 2, 2017
7fc247a
New Problem Solution "Wiggle Sort II"
haoel Jan 2, 2017
86f9497
New Problem Solution "Verify Preorder Serialization of a Binary Tree"
haoel Jan 6, 2017
121b458
New Problem Solution "Reconstruct Itinerary"
haoel Jan 6, 2017
271fb95
added totalHammingDistance
Vally79 Jan 9, 2017
2ee4f1f
Merge pull request #129 from Vally79/master
Vally79 Jan 9, 2017
1625e4a
fix index out of range
se77en Jan 18, 2017
a99649d
Merge pull request #130 from se77en/patch-1
haoel Mar 15, 2017
fe04640
New solution for "Reverse Vowels of a String"
haoel Mar 21, 2017
ad9d290
New Problem Solution "Palindrome Pairs"
haoel Mar 22, 2017
0cf4a89
add drive ai questions P1
yiakwy Apr 12, 2017
1567d0e
add new problem
yiakwy Apr 12, 2017
007e5a1
New Problem Solution "Sentence Screen Fitting"
yiakwy Nov 28, 2016
0398a78
add heart
yiakwy Nov 28, 2016
27c10d3
New method (non recursive) for CourseSchedule
yiakwy Nov 28, 2016
ace44a5
add drive ai questions P1
yiakwy Apr 12, 2017
8c947bc
add new problem
yiakwy Apr 12, 2017
b522011
fix
yiakwy Apr 13, 2017
109c6d6
杨氏矩阵的查找
kosoraYintai Jan 27, 2018
70f6a59
Test for problem 240
kosoraYintai Jan 27, 2018
1a6c424
Comments for problem 240
kosoraYintai Jan 27, 2018
fb1dc6e
杨氏矩阵的查找
kosoraYintai Jan 27, 2018
59eee6f
Test for problem 240
kosoraYintai Jan 27, 2018
eee437f
Comments for problem 240
kosoraYintai Jan 27, 2018
f037a8e
read me format
Sep 18, 2017
b4b73ec
handle cases with input array size < 3
karanchawla Oct 8, 2017
92562b3
added database support
Jun 5, 2017
f7c374f
Merge pull request #1 from haoel/master
kosoraYintai Jan 31, 2018
ca71b67
Leetcode changed the frontend to GraphQL API, the scripts need to ada…
haoel Feb 1, 2018
2338d1f
move the xidel installation script from comments.sh to lib/query_prob…
haoel Feb 2, 2018
dffcf2e
typo fix, close #120
haoel Feb 2, 2018
47a220b
Merge branch 'master' of https://github.com/yiakwy/leetcode into yiak…
haoel Feb 2, 2018
b838e2f
Merge branch 'yiakwy-master'
haoel Feb 2, 2018
551993a
Create firstMd.md
kosoraYintai Feb 2, 2018
4712378
Update firstMd.md
kosoraYintai Feb 2, 2018
b5729f6
Update firstMd.md
kosoraYintai Feb 2, 2018
2b133ce
deleteMd haha
kosoraYintai Feb 2, 2018
63341a8
Merge pull request #2 from haoel/master
kosoraYintai Feb 2, 2018
1b630ca
Some array、stack、queue solution for leetcode
kosoraYintai Feb 2, 2018
cf79335
Readme.md for problem 26, problem 155, problem 189, problem 225 and p…
kosoraYintai Feb 2, 2018
7b83329
rename dir/file
kosoraYintai Feb 3, 2018
1da21ef
rename dir/file
kosoraYintai Feb 3, 2018
f31071e
rename dir/file
kosoraYintai Feb 3, 2018
ec2c5f7
Merge branch 'kosoraYintai-master'
haoel Feb 4, 2018
eb6b031
remove `DockerCircles` and add problem description for sentence seree…
haoel Feb 4, 2018
9e4c01b
fix the bug
andyli029 Aug 12, 2017
cfd9293
[Linux]fix the download link - xidel download link seems use differen…
haoel Feb 5, 2018
0fdf100
fix: the xidel rename the -q option to -s after 0.9.4 version, so we …
haoel Feb 5, 2018
726e762
Java Solution for 9、38、50、58、92、125、151、206、242, KMP for problem 9
kosoraYintai Feb 11, 2018
725a380
Java Solution for 9、38、50、58、92、125、151、206、242, KMP for problem 9
kosoraYintai Feb 11, 2018
cd38a47
Two New Problem Solution - "Most Common Word" and "Maximum Average Su…
haoel Apr 19, 2018
5dea314
fix the comments.sh which use the new leetcode API to retrive problem…
haoel Apr 19, 2018
4d48134
[fix] - adopted the new leetcode GrapQL API
haoel Jun 23, 2018
b98dab8
[New Solution] - "Jewels and Stones"
haoel Jun 23, 2018
956807c
[fix] fix the bugs of DP
haoel Jun 23, 2018
dcaa897
[fix] remove the debug loging
haoel Jun 24, 2018
a3483c9
New Solution "Partition Equal Subset Sum"
haoel Jun 25, 2018
7228f4e
Updated an simple solution for two easy problems
haoel Jun 25, 2018
034fee5
New Solution - "Sum of Two Integers"
haoel Jun 25, 2018
e364610
New Solution "Valid Perfect Square"
haoel Jun 25, 2018
e66a31f
fix: using `questionFrontendId` instead of `questionId`
haoel Jun 27, 2018
93d6399
New Solution "Mirror Reflection"
haoel Jun 27, 2018
fdf5f82
New Solution "Buddy Strings"
haoel Jun 27, 2018
42ec491
New Solution "Unique Morse Code Words"
haoel Jun 29, 2018
3076f88
New Solution"Peak Index in a Mountain Array"
haoel Jun 29, 2018
9de0296
New Solution "Backspace String Compare"
haoel Jun 29, 2018
7df02ee
New Solution "Integer Replacement"
ehds Aug 1, 2018
557834f
add python solution to some questions
Kurt-Yu Dec 22, 2018
00af522
added python solution to some problems
Kurt-Yu Dec 26, 2018
f01883e
added python solutions to some problems
Kurt-Yu Dec 31, 2018
c08e32f
added python solutions to some problems
Kurt-Yu Jan 2, 2019
f1e4d92
added python solutions to some problems
Kurt-Yu Jan 9, 2019
01320b2
added some python solutions
Kurt-Yu Jan 14, 2019
f380f20
added some python solutions
Kurt-Yu Jan 21, 2019
b9196c3
added some python solutions
Kurt-Yu Jan 23, 2019
c28ac08
added some python solutions
Kurt-Yu Jan 25, 2019
ed86932
fixed a small markdown syntax
Kurt-Yu Jan 25, 2019
046bb1c
fix the graphQL API request payload body
haoel Jan 26, 2019
00482f1
fix the bug with question title
haoel Jan 26, 2019
f54ad38
optimized the scripts to generate the comments
haoel Jan 26, 2019
d73a5a0
New Solution "Longest Turbulent Subarray"
haoel Jan 27, 2019
35ecea3
New Problem Solution "String Without AAA or BBB"
haoel Jan 29, 2019
bcb337f
New Problem Solution "Minimum Cost For Tickets"
haoel Jan 29, 2019
d675cfa
missed coommit the source files
haoel Jan 29, 2019
50a6de1
New Problem Solution "Time Based Key-Value Store"
haoel Jan 30, 2019
ef13f1e
New Problem Solution "Palindromic Substrings"
haoel Jan 30, 2019
e1012ef
New Problem Solution "Minimum Falling Path Sum"
haoel Jan 30, 2019
b0daa57
New Problem Solution "Minimum ASCII Delete Sum for Two String"
haoel Jan 30, 2019
0f15689
fix #165 - correct the difficulty level
haoel Jan 30, 2019
6fcccec
correct the link from "https://oj.leetcode.com/" to "https://leetcode…
haoel Jan 30, 2019
59204d7
fix #160 - when the input is "-2147483648 -1",the array named bit_num…
haoel Jan 30, 2019
56f72e6
optimzing the logic - reduced the control state
haoel Jan 31, 2019
b6fe67c
optimzing the code
haoel Jan 31, 2019
0b8e7d9
New Problem Solution "Best Time to Buy and Sell Stock with Transactio…
haoel Feb 1, 2019
7249bc3
New Problem Solution "Best Time to Buy and Sell Stock with Cooldown"
haoel Feb 1, 2019
4d762f4
add a new simpler solution
haoel Feb 2, 2019
d07df71
New Problem Solution "Unique Paths III"
haoel Feb 4, 2019
4b2f4d0
optimzating the implementation of Unique Paths I/II
haoel Feb 4, 2019
9b23fc2
New Problem C++ Solution - "Min Cost Climbing Stairs"
haoel Feb 4, 2019
0cda1f9
New Problem Solution "Detect Capital"
haoel Feb 4, 2019
fe4dd65
New Problem Solution "Island Perimeter"
haoel Feb 4, 2019
0f0c10c
New Problem Solution - "Sum of Even Numbers After Queries"
haoel Feb 5, 2019
b585d36
New Problem Solution - "Smallest String Starting From Leaf"
haoel Feb 5, 2019
b5e252b
New Problem Solution - "Vertical Order Traversal of a Binary Tree"
haoel Feb 5, 2019
fed3639
New Probelm Solution = "Interval List Intersections"
haoel Feb 5, 2019
3b49afb
added a recursive solution
haoel Mar 18, 2019
0674c9b
New Problem Solution "Coin Change 2"
haoel Mar 18, 2019
1965803
fix uniquePaths.II solution
ehds Feb 26, 2019
a8bdcb8
fix uniquePaths.II cpp solution
ehds Feb 26, 2019
5f94d17
fix uniquePaths.II cpp solution
ehds Feb 26, 2019
8bc818a
fix #167 : need to check `y` is overflowed
haoel Mar 18, 2019
054e426
New Problem Solution - "Game of Life"
haoel Mar 20, 2019
1b0bf37
add Hao's implementation
haoel Mar 21, 2019
4905e7f
New Problem Solution "Count Numbers with Unique Digits"
haoel Mar 24, 2019
5353720
House Robber III - another implementation
haoel Mar 24, 2019
395a4d8
reformat the script
haoel Mar 25, 2019
86183f9
fix the bug - tr: Illegal byte sequence
haoel Mar 25, 2019
f18b025
New Problem Solution "Add to Array-Form of Integer"
haoel Mar 25, 2019
2f01d89
New Problem Solution "Satisfiability of Equality Equations"
haoel Mar 25, 2019
646a155
fix: funciton name
haoel Mar 26, 2019
2ed6107
New Problem C++ Solution - "Squares of a Sorted Array"
haoel Mar 26, 2019
30fbc75
New Problem Solution - "Sort Array By Parity"
haoel Mar 26, 2019
e381e32
New Problem Solution - "Sort Array By Parity II"
haoel Mar 26, 2019
7d61861
New Problem C++ Solution - "Fibonacci Number"
haoel Mar 26, 2019
97ca258
New Problem Solution - "Max Area of Island"
haoel Mar 26, 2019
d099f61
slightly reformat the code
haoel Mar 26, 2019
ab23bb7
New Problem Solution - "Friend Circles"
haoel Mar 26, 2019
f5859be
New Problem Solution - "Accounts Merge"
haoel Mar 28, 2019
c20038f
New Problem Solution - "Distribute Coins in Binary Tree"
haoel Mar 29, 2019
db99fe1
no tricky solution
haoel Mar 29, 2019
2017083
refactory the code to make it a bit readable
haoel Mar 30, 2019
5db7fa4
more solutions
haoel Mar 30, 2019
4bffdab
more readable implementation
haoel Mar 30, 2019
1ebef5c
slight midification and removed the debug code
haoel Mar 31, 2019
56720e9
simplified the implmentation
haoel Mar 31, 2019
4c98ae0
fixed some algorithm bugs
haoel Apr 1, 2019
8a82252
fixed the algorithm bug
haoel Apr 2, 2019
d0b2896
update the comments
haoel Apr 2, 2019
d3946ff
more clean implementation
haoel Apr 2, 2019
8e851c8
update the implmetation
haoel Apr 2, 2019
c4e9249
update the problem description
haoel Apr 3, 2019
8e8d43d
refactory the code : show the evolution of the solution
haoel Apr 3, 2019
6d30ea6
reformat the comments
haoel Apr 3, 2019
ff4280d
more clean implementation
haoel Apr 3, 2019
3866064
update the comments
haoel Apr 8, 2019
aad9846
add n TLE solution
haoel Apr 8, 2019
ba6a84d
New Problem Solution - "Two City Scheduling"
haoel Apr 21, 2019
6c9f558
New Problem Solution - "Matrix Cells in Distance Order"
haoel Apr 21, 2019
467fd31
New Problem Solution "Cousins in Binary Tree"
haoel Apr 30, 2019
bb0ede1
New Problem Solution "Broken Calculator"
haoel Apr 30, 2019
3564a92
New C++ Solution "Largest Perimeter Triangle"
yue2388253 Apr 7, 2019
f15b164
New C++ Solution "Largest Perimeter Triangle"
yue2388253 Apr 7, 2019
406871b
Update IntegerBreak.cpp
LynnTh May 14, 2019
eab7816
recoverTreeFromPreorderTraversal.cpp
AhmedMorsy95 May 19, 2019
1ddea28
refine the file name and the problem description comment #172
haoel May 29, 2019
1f3f2db
addTwoNumbers golang solution
May 29, 2019
9f09f91
modify name to twoSum and readme
May 29, 2019
7191254
add ,
May 29, 2019
27c5c9e
modify golang file name
May 29, 2019
18d72f2
add an log alias in git config file
haoel May 29, 2019
1314a81
New Problem Solution "Compare Strings by Frequency of the Smallest Ch…
haoel Oct 1, 2019
bde5dff
New Problem Solution "Video Stitching"
haoel Oct 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ LeetCode

| # | Title | Solution | Difficulty |
|---| ----- | -------- | ---------- |
|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii/) | [C++](./algorithms/cpp/intersectionOfTwoArraysII/intersectionOfTwoArraysII.cpp)|Easy|
|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays/) | [C++](./algorithms/cpp/intersectionOfTwoArrays/intersectionOfTwoArrays.cpp)|Easy|
|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/) | [C++](./algorithms/cpp/topKFrequentElements/topKFrequentElements.cpp)|Medium|
|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string/) | [C++](./algorithms/cpp/reverseVowelsOfAString/reverseVowelsOfAString.cpp)|Easy|
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Source : https://leetcode.com/problems/intersection-of-two-arrays-ii/
// Author : Calinescu Valentin
// Date : 2016-05-22

/***************************************************************************************
*
* Given two arrays, write a function to compute their intersection.
*
* Example:
* Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].
*
* Note:
* Each element in the result should appear as many times as it shows in both arrays.
* The result can be in any order.
*
* Follow up:
* What if the given array is already sorted? How would you optimize your algorithm?
* What if nums1's size is small compared to num2's size? Which algorithm is better?
* What if elements of nums2 are stored on disk, and the memory is limited such that you
* cannot load all elements into the memory at once?
*
***************************************************************************************/

/* Solution
* --------
*
* Follow up:
*
* 1)If the given array is already sorted we can skip the sorting.
*
* 2)If nums1 is significantly smaller than nums2 we can only sort nums1 and then binary
* search every element of nums2 in nums1 with a total complexity of (MlogN) or if nums2
* is already sorted we can search every element of nums1 in nums2 in O(NlogM)
*
* 3)Just like 2), we can search for every element in nums2, thus having an online
* algorithm.
*/

class Solution { // O(NlogN + MlogM)
public:
vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {
sort(nums1.begin(), nums1.end());//we sort both vectors in order to intersect
sort(nums2.begin(), nums2.end());//them later in O(N + M), where N = nums1.size()
vector <int> solution; //M = nums2.size()
int index = 0;
bool finished = false;
for(int i = 0; i < nums1.size() && !finished; i++)
{
while(index < nums2.size() && nums1[i] > nums2[index])//we skip over the
index++;//smaller elements in nums2
if(index == nums2.size())//we have reached the end of nums2 so we have no more
finished = true;//elements to add to the intersection
else if(nums1[i] == nums2[index])//we found a common element
{
solution.push_back(nums1[i]);
index++;
}
}
return solution;
}
};