Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions #442/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* https://leetcode.com/problems/find-all-duplicates-in-an-array/
*/

class Solution {
public List<Integer> findDuplicates(int[] nums) {
List<Integer> duplicates = new ArrayList<Integer>();
Set<Integer> noDupes = new HashSet<Integer>();
for (int i = 0; i < nums.length; i++){
if(noDupes.add(nums[i]) == false) {
duplicates.add(nums[i]);
}
}
return duplicates;
}
}
15 changes: 15 additions & 0 deletions #70/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int climbStairs(int n) {
if(n ==1) {
return n;
}
int first = 1;
int second = 2;
for (int i = 3; i <= n; i++) {
int third = first + second;
first = second;
second = third;
}
return second;
}
}