From 5d313acbf31b843ccda3ad47273e327a92484d40 Mon Sep 17 00:00:00 2001 From: ruhijam3 Date: Wed, 4 Sep 2024 14:08:24 -0400 Subject: [PATCH 1/2] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 43bd58d..c1b6250 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Below are the instructions for this assignment. Your repository should automatic ### 📝 TODO: Complete this section -* **Your name and PID**: +* **Your name and PID**: Ruhi Jame (ruhijame) -* **Your partner's name and PID:** +* **Your partner's name and PID:** Sanjana Ghanta (gsanjana) -* **Link to selected coding challenge:** +* **Link to selected coding challenge:** https://leetcode.com/problems/reverse-words-in-a-string/description/?envType=study-plan-v2&envId=leetcode-75 -* **Summary of partner's interview feedback:** +* **Summary of partner's interview feedback:** Vocalized thought process well and explained logic that was written, was able to adapt when errors were present and test cases were not passing From ca02f1a0a8bfe4a4c540cb03a2a6c5c8b98eb842 Mon Sep 17 00:00:00 2001 From: ruhijam3 Date: Wed, 4 Sep 2024 14:09:55 -0400 Subject: [PATCH 2/2] Create leetCodeSolution --- leetCodeSolution | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 leetCodeSolution diff --git a/leetCodeSolution b/leetCodeSolution new file mode 100644 index 0000000..f5c4f5c --- /dev/null +++ b/leetCodeSolution @@ -0,0 +1,24 @@ +class Solution { + public String reverseWords(String s) { + String result = ""; + + String[] words = s.trim().split("\\s+"); + + for (int i = words.length - 1; i >= 0; i--) { + if (words[0].equals(" ")) { + break; + } + else if (i >= 1) { + result = result + words[i] + " "; + } + else { + result = result + words[i]; + } + } + //System.out.println(words[0]); + //result = result + words[0]; + //System.out.println(words[1]); + + return result; + } +}