From 0737ada57797fd31af63e5c2988750869949f01f Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Mon, 28 Jul 2025 16:49:29 -0500 Subject: [PATCH 1/3] exercise solutions --- solutions/exercise solutions.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/exercise solutions.js diff --git a/solutions/exercise solutions.js b/solutions/exercise solutions.js new file mode 100644 index 0000000..e69de29 From cac378e458af8fba2fe5215f579e1a849930035e Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Sun, 31 Aug 2025 20:22:48 -0500 Subject: [PATCH 2/3] Two_sum: --- .idea/2025-software-dev-problem-set.iml | 9 +++++++++ solutions/.idea/.gitignore | 3 +++ solutions/.idea/misc.xml | 6 ++++++ solutions/.idea/modules.xml | 8 ++++++++ solutions/.idea/solutions.iml | 9 +++++++++ solutions/.idea/vcs.xml | 6 ++++++ 6 files changed, 41 insertions(+) create mode 100644 .idea/2025-software-dev-problem-set.iml create mode 100644 solutions/.idea/.gitignore create mode 100644 solutions/.idea/misc.xml create mode 100644 solutions/.idea/modules.xml create mode 100644 solutions/.idea/solutions.iml create mode 100644 solutions/.idea/vcs.xml diff --git a/.idea/2025-software-dev-problem-set.iml b/.idea/2025-software-dev-problem-set.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/2025-software-dev-problem-set.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/solutions/.idea/.gitignore b/solutions/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/solutions/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/solutions/.idea/misc.xml b/solutions/.idea/misc.xml new file mode 100644 index 0000000..31e1ebc --- /dev/null +++ b/solutions/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/solutions/.idea/modules.xml b/solutions/.idea/modules.xml new file mode 100644 index 0000000..7d282b8 --- /dev/null +++ b/solutions/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/solutions/.idea/solutions.iml b/solutions/.idea/solutions.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/solutions/.idea/solutions.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/solutions/.idea/vcs.xml b/solutions/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/solutions/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 71e0cf4feced776c518a1cd9c248bd503698e63a Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Tue, 2 Sep 2025 19:43:26 -0500 Subject: [PATCH 3/3] group anagram --- solutions/.idea/solutions.iml | 4 +++- solutions/Group_Anagram.java | 19 +++++++++++++++++++ solutions/Two_Sum.java | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 solutions/Group_Anagram.java create mode 100644 solutions/Two_Sum.java diff --git a/solutions/.idea/solutions.iml b/solutions/.idea/solutions.iml index d6ebd48..b107a2d 100644 --- a/solutions/.idea/solutions.iml +++ b/solutions/.idea/solutions.iml @@ -2,7 +2,9 @@ - + + + diff --git a/solutions/Group_Anagram.java b/solutions/Group_Anagram.java new file mode 100644 index 0000000..398ea5b --- /dev/null +++ b/solutions/Group_Anagram.java @@ -0,0 +1,19 @@ +import java.util.*; + +public class Group_Anagram { + public List> groupAnagrams(String[] strs) { + Map> res = new HashMap<>; + + for(String s : strs){ + int[] count = new int[26]; + for(char c : s.toCharArray()){ + count[c - 'a']++; + } + + String key = Arrays.toString(count); + res.putIfAbsent(key, new ArrayList<>); + res.get(key).add(s); + } + return new ArrayList<>(res.values()); + } +} diff --git a/solutions/Two_Sum.java b/solutions/Two_Sum.java new file mode 100644 index 0000000..bce825d --- /dev/null +++ b/solutions/Two_Sum.java @@ -0,0 +1,20 @@ +import java.util.HashMap; + +public class Two_Sum { + public int[] twoSum(int[] nums, int target) { + HashMap prevMap = new HashMap<>(); + + for (int i = 0; i < nums.length; i++) { + int num = nums[i]; + int diff = target - num; + + + if (prevMap.containsKey(diff)) { + return new int[]{prevMap.get(diff), i}; + } + prevMap.put(num, i); + } + return new int[]{}; + } + } +