From 0737ada57797fd31af63e5c2988750869949f01f Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Mon, 28 Jul 2025 16:49:29 -0500 Subject: [PATCH 01/28] 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 a0d9815167d7c559febf1467d646febf246fb66e Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Thu, 7 Aug 2025 20:00:55 -0500 Subject: [PATCH 02/28] exercise 2 --- solutions/Valid Anagram.js | 0 solutions/exercise solutions.js | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 solutions/Valid Anagram.js diff --git a/solutions/Valid Anagram.js b/solutions/Valid Anagram.js new file mode 100644 index 0000000..e69de29 diff --git a/solutions/exercise solutions.js b/solutions/exercise solutions.js index e69de29..48202a1 100644 --- a/solutions/exercise solutions.js +++ b/solutions/exercise solutions.js @@ -0,0 +1,22 @@ +/** + * @param {number[]} nums + * @return {boolean} + */ +var containsDuplicate = function(nums) { + + for (i = 0; i < nums.length; i++) { + let value = nums[i]; + + for (j = i + 1; j < nums.length; j++){ + let dupliValue = nums[j]; + + if(value === dupliValue){ + return true; + } + + + } + } + return false; + } + From 3cf334195b611e7e32fc817cf2793b3a09e681ba Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Sat, 9 Aug 2025 21:21:01 -0500 Subject: [PATCH 03/28] two sum --- solutions/Two_Sum.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/Two_Sum.js diff --git a/solutions/Two_Sum.js b/solutions/Two_Sum.js new file mode 100644 index 0000000..e69de29 From 29414e4ef207c08606a1910423b9444a7a12d4e8 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Sun, 10 Aug 2025 20:35:43 -0500 Subject: [PATCH 04/28] group anagrams --- solutions/Group Anagrams.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/Group Anagrams.js diff --git a/solutions/Group Anagrams.js b/solutions/Group Anagrams.js new file mode 100644 index 0000000..e69de29 From ed3ff739d7cfce14cfd0c2148168aebb762bf92e Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 27 Aug 2025 17:35:23 -0500 Subject: [PATCH 05/28] Contains Duplicate --- solutions/ContainsDuplicate_Java.js | 0 solutions/Group Anagrams.js | 24 ++++++++++++++++++++++++ solutions/Two_Sum.js | 13 +++++++++++++ solutions/Valid Anagram.js | 19 +++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 solutions/ContainsDuplicate_Java.js create mode 100644 solutions/Group Anagrams.js create mode 100644 solutions/Two_Sum.js create mode 100644 solutions/Valid Anagram.js diff --git a/solutions/ContainsDuplicate_Java.js b/solutions/ContainsDuplicate_Java.js new file mode 100644 index 0000000..e69de29 diff --git a/solutions/Group Anagrams.js b/solutions/Group Anagrams.js new file mode 100644 index 0000000..e0ff2c8 --- /dev/null +++ b/solutions/Group Anagrams.js @@ -0,0 +1,24 @@ +class Solution { + /** + * @param {string[]} strs + * @return {string[][]} + */ + groupAnagrams(strs) { + res = {}; + + for(let s in strs){ + let count = Array(26).fill(0); + + for(let letter in s){ + count[letter.charCodeAt(0) - 'a'.charCodeAt(0)] += 1; + } + const key = count.join(','); + + if(!res[key]){ + res[key] = []; + } + res[key].push(s); + } + return Object.values(res); +} +} \ No newline at end of file diff --git a/solutions/Two_Sum.js b/solutions/Two_Sum.js new file mode 100644 index 0000000..864b949 --- /dev/null +++ b/solutions/Two_Sum.js @@ -0,0 +1,13 @@ + +var twoSum = function(nums, target) { + + for (let i = 0; i < nums.length; i++){ + for(let j = i + 1; j < nums.length; j++){ + if(nums[i] + nums[j] == target){ + return[i, j]; + } + } + + } + return null; +}; \ No newline at end of file diff --git a/solutions/Valid Anagram.js b/solutions/Valid Anagram.js new file mode 100644 index 0000000..a68c1bc --- /dev/null +++ b/solutions/Valid Anagram.js @@ -0,0 +1,19 @@ +/** + * @param {string} s + * @param {string} t + * @return {boolean} + */ +var isAnagram = function(s, t) { + + if(s.length !== t.length){ + return false + } + + let counter = Array(26).fill(0); + for(let i = 0; i < s.length; i++) { + counter[s.charCodeAt(i) - 97]++; + counter[t.charCodeAt(i) - 97]--; + } + + return counter.every(count => count === 0); +} \ No newline at end of file From b8678d90fa07ce5619e2a121041e095d8e6ba4cb Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 27 Aug 2025 17:53:29 -0500 Subject: [PATCH 06/28] Valid Anagram --- solutions/ValidAnagrams_Java.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 solutions/ValidAnagrams_Java.js diff --git a/solutions/ValidAnagrams_Java.js b/solutions/ValidAnagrams_Java.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 07/28] 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 08/28] 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[]{}; + } + } + From 6088ea368a20b728287257467e9ebc4eea04473c Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 3 Sep 2025 13:56:01 -0500 Subject: [PATCH 09/28] Top Freq k --- solutions/Group_Anagram.java | 6 +++--- solutions/TopKFreq.java | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 solutions/TopKFreq.java diff --git a/solutions/Group_Anagram.java b/solutions/Group_Anagram.java index 398ea5b..05fac4b 100644 --- a/solutions/Group_Anagram.java +++ b/solutions/Group_Anagram.java @@ -4,14 +4,14 @@ public class Group_Anagram { public List> groupAnagrams(String[] strs) { Map> res = new HashMap<>; - for(String s : strs){ + for (String s : strs) { int[] count = new int[26]; - for(char c : s.toCharArray()){ + for (char c : s.toCharArray()) { count[c - 'a']++; } String key = Arrays.toString(count); - res.putIfAbsent(key, new ArrayList<>); + res.putIfAbsent(key, new ArrayList()); res.get(key).add(s); } return new ArrayList<>(res.values()); diff --git a/solutions/TopKFreq.java b/solutions/TopKFreq.java new file mode 100644 index 0000000..5ff6092 --- /dev/null +++ b/solutions/TopKFreq.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +class Solution { + public int[] topKFrequent(int[] nums, int k){ + Map count = new HashMap<>(); + + for(int n : nums){ + count.put(n, count.getOrDefault(n, 0) + 1); + } + + List[] freq = new List[nums.length + 1]; + for(int i = 0; i < freq.length; i++){ + freq[i] = new ArrayList<>; + } + + for(Map.Entry entry : count.entrySet()){ + freq[entry.getValue()].add(entry.getKey()); + } + + int[] res = new int[k]; + int index = 0; + for(int i = freq.length - 1; i > 0 && index < k; i--){ + for(int n : freq[i]) { + res[index++] = n; + if(index == k){ + return res; + } + } + } + return res; + } +} From 932d089847e1b8b0a29e0aaba3f9bc3a9ef45e2f Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 3 Sep 2025 20:53:39 -0500 Subject: [PATCH 10/28] Product of array --- solutions/ProductofArrayXItself.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 solutions/ProductofArrayXItself.java diff --git a/solutions/ProductofArrayXItself.java b/solutions/ProductofArrayXItself.java new file mode 100644 index 0000000..7345fa9 --- /dev/null +++ b/solutions/ProductofArrayXItself.java @@ -0,0 +1,17 @@ +public class ProductofArrayXItself { + + int n = nums.length; + int[] res = new int[n]; + + int res[0] = 1; + for(int i = 1; i < n; i++){ + res[i] = res[i - 1] * nums[i - 1]; + } + + int postfix = 1; + for(int i = n - 1; i >= 0; i--){ + res[i] *= postfix; + postfix *= nums[i]; + } + return res; +} From e54e0dbd38baec0e74223f0dd61661ea493579a5 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Thu, 4 Sep 2025 18:53:06 -0500 Subject: [PATCH 11/28] valid sudoku --- solutions/ValidSydoku.java | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 solutions/ValidSydoku.java diff --git a/solutions/ValidSydoku.java b/solutions/ValidSydoku.java new file mode 100644 index 0000000..69a3add --- /dev/null +++ b/solutions/ValidSydoku.java @@ -0,0 +1,39 @@ +import java.util.HashSet; +import java.util.Set; + +class Solution { + public boolean isValidSudoku(char[][] board) { + + for (int row = 0; row < 9; row++) { + Set seen = new HashSet<>(); + for (int i = 0; i < 9; i++) { + if (board[row][i] == '.') continue; + if (seen.contains(board[row][i])) return false; + seen.add(board[row][i]); + } + } + + for (int col = 0; col < 9; col++) { + Set seen = new HashSet<>(); + for (int i = 0; i < 9; i++) { + if (board[i][col] == '.') continue; + if (seen.contains(board[i][col])) return false; + seen.add(board[i][col]); + } + } + + for (int square = 0; square < 9; square++) { + Set seen = new HashSet<>(); + for (int i = 0; i < 9; i++) { + for (int j = 0; j < 9; j++) { + int row = (square / 3) * 3 + i; + int col = (square % 3) * 3 + j; + if (board[row][col] == '.') continue; + if (seen.contains(board[row][col])) return false; + seen.add(board[row][col]); + } + } + } + return true; + } +} \ No newline at end of file From 9c9080bf001b620a0f34af357e1a5b25b11fb957 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Thu, 4 Sep 2025 18:56:06 -0500 Subject: [PATCH 12/28] Longest conseq seq branch --- solutions/LConsSeq.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 solutions/LConsSeq.java diff --git a/solutions/LConsSeq.java b/solutions/LConsSeq.java new file mode 100644 index 0000000..6e1050a --- /dev/null +++ b/solutions/LConsSeq.java @@ -0,0 +1,5 @@ +class Solution { + public int longestConsecutive(int[] nums) { + + } +} \ No newline at end of file From bad6edaafb3f2aafac88409f5d375d31efb049a3 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Tue, 9 Sep 2025 20:34:48 -0500 Subject: [PATCH 13/28] Longest Conseq Sequence --- solutions/LConsSeq.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/solutions/LConsSeq.java b/solutions/LConsSeq.java index 6e1050a..b386149 100644 --- a/solutions/LConsSeq.java +++ b/solutions/LConsSeq.java @@ -1,5 +1,19 @@ +import java.util.HashMap; +import java.util.Map; + class Solution { public int longestConsecutive(int[] nums) { + Map mp = new HashMap<>(); + int res = 0; + for(int num : nums){ + if (!mp.containsKey(num)){ + mp.put(num, mp.getOrDefault(num - 1, 0) + mp.getOrDefault(num + 1, 0) + 1); + mp.put(num - mp.getOrDefault(num - 1, 0), mp.get(num)); + mp.put(num + mp.getOrDefault(num + 1, 0), mp.get(num)); + res = Math.max(res, mp.get(num)); + } + } + return res; } } \ No newline at end of file From 6cd78286fff6fcf19589e448b11ba26868db3a9d Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 10 Sep 2025 17:39:46 -0500 Subject: [PATCH 14/28] valid palindrome java --- solutions/ValidPalindrome.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solutions/ValidPalindrome.java diff --git a/solutions/ValidPalindrome.java b/solutions/ValidPalindrome.java new file mode 100644 index 0000000..7efa143 --- /dev/null +++ b/solutions/ValidPalindrome.java @@ -0,0 +1,25 @@ +class Solution { + public boolean isPalindrome(String s) { + int l = 0, r = s.length() - 1; + + while(l < r){ + while(l < r && !alphaNum(s.charAt(l))){ + l++; + } + while(r > l && !alphaNum(s.charAt(r))){ + r--; + } + if(Character.toLowerCase(s.charAt(l)) != Character.toLowerCase(s.charAt(r))){ + return false; + } + l++; r--; + } + return true; + } + + public boolean alphaNum(char c){ + return (c >= 'A' && c <= 'Z' || + c >= 'a' && c <= 'z' || + c >= '0' && c <= '9'); + } + } From eaf6f9b24c33d9956732e4339f0b04c55dc8ee43 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 10 Sep 2025 18:02:29 -0500 Subject: [PATCH 15/28] Two Sum II java --- solutions/TwoSum2.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 solutions/TwoSum2.java diff --git a/solutions/TwoSum2.java b/solutions/TwoSum2.java new file mode 100644 index 0000000..01c635a --- /dev/null +++ b/solutions/TwoSum2.java @@ -0,0 +1,18 @@ +class Solution { + public int[] twoSum(int[] numbers, int target) { + int l = 0, r = numbers.length - 1; + + while(l < r){ + int curSum = numbers[l] + numbers[r]; + + if(curSum > target){ + r--; + } else if (curSum < target){ + l++; + } else { + return new int[] = {l + 1, r + 1}; + } + } + return new int[0]; + } +} \ No newline at end of file From c277382e61ce661dab27d43924b2b0fa317d8ab4 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Thu, 11 Sep 2025 15:57:49 -0500 Subject: [PATCH 16/28] three sum --- solutions/Three_Sum.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 solutions/Three_Sum.java diff --git a/solutions/Three_Sum.java b/solutions/Three_Sum.java new file mode 100644 index 0000000..4a6946f --- /dev/null +++ b/solutions/Three_Sum.java @@ -0,0 +1,32 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +class Solution { + public List> threeSum(int[] nums) { + Arrays.sort(nums); + List> res = new ArrayList<>(); + for(int i = 0; i < nums.length; i++){ + if(nums[i] > 0) break; + if(i > 0 && nums[i] == nums[i - 1]) continue; + + int l = i + 1, r = nums.length - 1; + while(l < r){ + int sum = nums[i] + nums[l] + nums[r]; + if(sum > 0){ + r--; + } else if (sum < 0){ + l++; + } else { + res.add(Arrays.asList(nums[i], nums[l], nums[r])); + l++; + r--; + while(l < r && (nums[l] == nums[l - 1]){ + l++; + } + } + } + } + return res; + } +} \ No newline at end of file From c079c4d24b53a860d947591a02cc81b850609331 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Tue, 16 Sep 2025 20:10:20 -0500 Subject: [PATCH 17/28] contain water --- solutions/ContainerWMostWater.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 solutions/ContainerWMostWater.java diff --git a/solutions/ContainerWMostWater.java b/solutions/ContainerWMostWater.java new file mode 100644 index 0000000..373dee9 --- /dev/null +++ b/solutions/ContainerWMostWater.java @@ -0,0 +1,18 @@ +class Solution { + public int maxArea(int[] height) { + int l = 0; + int r = height.length - 1; + int res = 0; + + while(l < r){ + int area = Math.min(height[l], height[r]) * (r - l); + res = Math.max(res, area); + if (height[l] <= height[r]) { + l++; + }else{ + r--; + } + } + return res; + } +} \ No newline at end of file From e9e4cc2a432246b03446f5b77417928203c87ed6 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 17 Sep 2025 20:49:07 -0500 Subject: [PATCH 18/28] valid_parentheses --- solutions/Valid_Parentheses.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 solutions/Valid_Parentheses.java diff --git a/solutions/Valid_Parentheses.java b/solutions/Valid_Parentheses.java new file mode 100644 index 0000000..735fcf4 --- /dev/null +++ b/solutions/Valid_Parentheses.java @@ -0,0 +1,24 @@ +import java.util.Stack; + +class Solution { + public boolean isValid(String s) { + Stack stack = new Stack<>(); + java.util.Map closeToOpen = new java.util.HashMap<>(); + closeToOpen.put(')', '('); + closeToOpen.put(']', '['); + closeToOpen.put('}', '{'); + + for(Character c : s.toCharArray()){ + if(closeToOpen.containsKey(c)){ + if(!stack.isEmpty() && stack.peek() == closeToOpen.get(c)) { + stack.pop(); + } else { + return false; + } + } else { + stack.push(c); + } + } + return stack.isEmpty(); + } + } From 088c28e833cdebe28afb780855cf45cc6b8263cb Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 17 Sep 2025 20:56:55 -0500 Subject: [PATCH 19/28] min stack --- solutions/Min_Stack.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 solutions/Min_Stack.java diff --git a/solutions/Min_Stack.java b/solutions/Min_Stack.java new file mode 100644 index 0000000..66e4aeb --- /dev/null +++ b/solutions/Min_Stack.java @@ -0,0 +1,31 @@ +class MinStack { + + public MinStack() { + + } + + public void push(int val) { + + } + + public void pop() { + + } + + public int top() { + + } + + public int getMin() { + + } +} + +/** + * Your MinStack object will be instantiated and called as such: + * MinStack obj = new MinStack(); + * obj.push(val); + * obj.pop(); + * int param_3 = obj.top(); + * int param_4 = obj.getMin(); + */ \ No newline at end of file From 44e411d5ef2162bb84cafaa662ccf52c9a20fc6f Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Sat, 20 Sep 2025 19:50:30 -0500 Subject: [PATCH 20/28] min stack --- solutions/Min_Stack.java | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/solutions/Min_Stack.java b/solutions/Min_Stack.java index 66e4aeb..abc2e95 100644 --- a/solutions/Min_Stack.java +++ b/solutions/Min_Stack.java @@ -1,23 +1,37 @@ +import java.util.Stack; + class MinStack { - public MinStack() { + private Stack stack = new Stack<>(); + public MinStack() { + stack = new Stack<>; } public void push(int val) { - + stack.push(val); } public void pop() { - + stack.pop(); } public int top() { - + return stack.peek(); } public int getMin() { - + Stack tmp = new Stack<>; + int mini = stack.peek(); + + while(!stack.isEmpty()){ + mini = Math.min(mini, stack.peek()); + tmp.push(stack.pop()); + } + while(!tmp.isEmpty()){ + stack.push(tmp.pop()); + } + return mini; } } From 80b0aafa966d3110485e8dec9a1504fa61c617de Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Mon, 22 Sep 2025 20:37:35 -0500 Subject: [PATCH 21/28] eval rev pol not --- solutions/Eval_Rev_Polish_Notation.java | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 solutions/Eval_Rev_Polish_Notation.java diff --git a/solutions/Eval_Rev_Polish_Notation.java b/solutions/Eval_Rev_Polish_Notation.java new file mode 100644 index 0000000..4bcfd9a --- /dev/null +++ b/solutions/Eval_Rev_Polish_Notation.java @@ -0,0 +1,26 @@ +import java.util.Stack; + +class Solution { + public int evalRPN(String[] tokens) { + Stack stack = new Stack<>(); + + for(String c : tokens){ + if(c.equals("+")){ + stack.push(stack.pop() + stack.pop()); + } else if(c.equals("-")){ + int a = stack.pop(); + int b = stack.pop(); + stack.push(b - a); + } else if(c.equals("*")){ + stack.push(stack.pop() * stack.pop()); + } else if(c.equals("/")){ + int a = stack.pop(); + int b = stack.pop(); + stack.push(b / a); + } else { + stack.push(Integer.parseInt(c)); + } + } + return stack.pop(); + } +} From 56d0a11071bb427b4d848879ec9b94ec8a3a8b6d Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Mon, 22 Sep 2025 20:40:59 -0500 Subject: [PATCH 22/28] creating generate parentheses --- solutions/Gen_Parentheses.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 solutions/Gen_Parentheses.java diff --git a/solutions/Gen_Parentheses.java b/solutions/Gen_Parentheses.java new file mode 100644 index 0000000..6d5d409 --- /dev/null +++ b/solutions/Gen_Parentheses.java @@ -0,0 +1,5 @@ +class Solution { + public List generateParenthesis(int n) { + + } +} \ No newline at end of file From fc6aeeb3896fec2e5b584057426d18c94ac54a1c Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 24 Sep 2025 20:20:36 -0500 Subject: [PATCH 23/28] gen parentheseis --- solutions/Gen_Parentheses.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/solutions/Gen_Parentheses.java b/solutions/Gen_Parentheses.java index 6d5d409..72a32c1 100644 --- a/solutions/Gen_Parentheses.java +++ b/solutions/Gen_Parentheses.java @@ -1,5 +1,30 @@ +import java.util.ArrayList; +import java.util.List; + class Solution { - public List generateParenthesis(int n) { + private void backtrack(int openN, int closedN, int n, List res, StringBuilder stack) { + if(openN == closedN && openN == n){ + res.add(stack.toString()); + return; + } + + if(openN < closedN){ + stack.append('('); + backtrack(openN + 1, closedN, n, res, stack); + stack.deleteCharAt(stack.length() - 1); + } + + if(closedN < openN){ + stack.append(')'); + backtrack(openN, closedN + 1, n, res, stack); + stack.deleteCharAt(stack.length() - 1); + } + public List generateParenthesis(int n){ + List res = new ArrayList<>(); + StringBuilder stack = new StringBuilder(); + backtrack(0, 0, n, res, stack); + return res; + } } } \ No newline at end of file From b5ef3c440724318ee408a276e0f2f192f9ceeb3e Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 24 Sep 2025 20:23:31 -0500 Subject: [PATCH 24/28] creating daily temps --- solutions/DailyTemps.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 solutions/DailyTemps.java diff --git a/solutions/DailyTemps.java b/solutions/DailyTemps.java new file mode 100644 index 0000000..536c2dd --- /dev/null +++ b/solutions/DailyTemps.java @@ -0,0 +1,2 @@ +public class DailyTemps { +} From 787e16945df03e4293157bf1b902d140d48b0d9d Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Tue, 7 Oct 2025 20:00:15 -0500 Subject: [PATCH 25/28] daily temps --- solutions/DailyTemps.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/solutions/DailyTemps.java b/solutions/DailyTemps.java index 536c2dd..dae1ce8 100644 --- a/solutions/DailyTemps.java +++ b/solutions/DailyTemps.java @@ -1,2 +1,17 @@ +import java.util.Stack; + public class DailyTemps { + int[] res = new int[temperatures.length]; + Stack stack = new Stack<>(); + + for(int i = 0; i < temperatures.length; i++){ + int t = temperatures[i]; + + while(!stack.isEmpty() && t > stack.peek()[0]){ + int[] pair = stack.pop(); + res[pair[1]] = i - pair[i]; + } + stack.push(new int[]{t, i}); + } + return res; } From 9a7f016d5c26fef3391a1682f7fc2baa8b07f6c2 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Mon, 1 Dec 2025 15:28:48 -0600 Subject: [PATCH 26/28] find min in rotated sorted array --- .idea/2025-software-dev-problem-set.iml | 4 +- .idea/misc.xml | 4 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ .idea/workspace.xml | 68 +++++++++++++++++++++++++ solutions/FindMinSortedArray.java | 16 ++++++ 6 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 solutions/FindMinSortedArray.java diff --git a/.idea/2025-software-dev-problem-set.iml b/.idea/2025-software-dev-problem-set.iml index d6ebd48..1335759 100644 --- a/.idea/2025-software-dev-problem-set.iml +++ b/.idea/2025-software-dev-problem-set.iml @@ -2,7 +2,9 @@ - + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..db51b41 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3cbc8d9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8cadc25 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 1764623963310 + + + + \ No newline at end of file diff --git a/solutions/FindMinSortedArray.java b/solutions/FindMinSortedArray.java new file mode 100644 index 0000000..717b430 --- /dev/null +++ b/solutions/FindMinSortedArray.java @@ -0,0 +1,16 @@ +public class FindMinSortedArray { + public int findMin(int[] nums){ + int l = 0; + int r = nums.length - 1; + + while(l < r){ + int m = l + (r - l) / 2; + if (nums[m] < nums[r]) { + r = m; + } else { + l = m + 1; + } + } + return nums[l]; + } +} From 8783507ca7487d3258215cb35dd1f4fa5ffc2c36 Mon Sep 17 00:00:00 2001 From: StaceyO21 Date: Wed, 3 Dec 2025 22:15:15 -0600 Subject: [PATCH 27/28] search rotated sorted array --- .idea/workspace.xml | 37 +++++++++++++----------- solutions/SearchNRotatedSortedArray.java | 26 +++++++++++++++++ 2 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 solutions/SearchNRotatedSortedArray.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8cadc25..410e04a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,9 +1,12 @@ + + - - + +