-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 20 additions & 1 deletion
21
big-o/src/main/java/com/josdem/algorithms/HalfSquareRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
package com.josdem.algorithms; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
/* Type: Square Time Algorithms – O(n^2/2) | ||
Description: Half-square increment amount of time based on collection size | ||
*/ | ||
|
||
public class HalfSquareRunner { | ||
private final Logger log = Logger.getLogger(this.getClass().getName()); | ||
public List<Integer> getTargetNumbers(List<Integer> numbers, int target) { | ||
return numbers; | ||
List<Integer> result = new ArrayList<>(); | ||
for(int i=0; i < numbers.size(); i++){ | ||
for(int j = i + 1; j < numbers.size(); j++){ | ||
int a = numbers.get(i); | ||
int b = numbers.get(j); | ||
if (a + b == target){ | ||
result.add(a); | ||
result.add(b); | ||
log.info(a + "," + b); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters