Nathan Hall 6 years ago
parent
commit
1887227f10
3 changed files with 135 additions and 70 deletions
  1. 56
    57
      arraz/.idea/workspace.xml
  2. 33
    10
      arraz/src/main/java/Arraz.java
  3. 46
    3
      arraz/src/test/java/ArrazTest.java

+ 56
- 57
arraz/.idea/workspace.xml View File

28
       </usages-collector>
28
       </usages-collector>
29
       <usages-collector id="statistics.file.types.edit">
29
       <usages-collector id="statistics.file.types.edit">
30
         <counts>
30
         <counts>
31
-          <entry key="JAVA" value="3847" />
31
+          <entry key="JAVA" value="4534" />
32
         </counts>
32
         </counts>
33
       </usages-collector>
33
       </usages-collector>
34
     </session>
34
     </session>
40
           <file pinned="false" current-in-tab="true">
40
           <file pinned="false" current-in-tab="true">
41
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
41
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
42
               <provider selected="true" editor-type-id="text-editor">
42
               <provider selected="true" editor-type-id="text-editor">
43
-                <state relative-caret-position="550">
44
-                  <caret line="197" column="16" lean-forward="true" selection-start-line="197" selection-start-column="16" selection-end-line="197" selection-end-column="16" />
43
+                <state relative-caret-position="94">
44
+                  <caret line="108" column="18" selection-start-line="108" selection-start-column="18" selection-end-line="108" selection-end-column="18" />
45
                   <folding>
45
                   <folding>
46
-                    <element signature="imports" expanded="true" />
46
+                    <element signature="e#1659#1668#0" expanded="true" />
47
                     <element signature="e#1375#1376#0" expanded="true" />
47
                     <element signature="e#1375#1376#0" expanded="true" />
48
                     <element signature="e#1410#1411#0" expanded="true" />
48
                     <element signature="e#1410#1411#0" expanded="true" />
49
                     <element signature="e#1454#1455#0" expanded="true" />
49
                     <element signature="e#1454#1455#0" expanded="true" />
68
           <file pinned="false" current-in-tab="true">
68
           <file pinned="false" current-in-tab="true">
69
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
69
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
70
               <provider selected="true" editor-type-id="text-editor">
70
               <provider selected="true" editor-type-id="text-editor">
71
-                <state relative-caret-position="73">
72
-                  <caret line="292" column="49" selection-start-line="292" selection-start-column="49" selection-end-line="292" selection-end-column="49" />
71
+                <state relative-caret-position="96">
72
+                  <caret line="339" column="15" selection-start-line="339" selection-start-column="15" selection-end-line="339" selection-end-column="15" />
73
                   <folding>
73
                   <folding>
74
                     <element signature="imports" expanded="true" />
74
                     <element signature="imports" expanded="true" />
75
                   </folding>
75
                   </folding>
99
     <sorting>DEFINITION_ORDER</sorting>
99
     <sorting>DEFINITION_ORDER</sorting>
100
   </component>
100
   </component>
101
   <component name="ProjectFrameBounds">
101
   <component name="ProjectFrameBounds">
102
-    <option name="x" value="-332" />
103
-    <option name="y" value="-934" />
104
-    <option name="width" value="1636" />
105
-    <option name="height" value="793" />
102
+    <option name="y" value="159" />
103
+    <option name="width" value="1280" />
104
+    <option name="height" value="747" />
106
   </component>
105
   </component>
107
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
106
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
108
   <component name="ProjectView">
107
   <component name="ProjectView">
159
   <component name="PropertiesComponent">
158
   <component name="PropertiesComponent">
160
     <property name="WebServerToolWindowFactoryState" value="false" />
159
     <property name="WebServerToolWindowFactoryState" value="false" />
161
     <property name="aspect.path.notification.shown" value="true" />
160
     <property name="aspect.path.notification.shown" value="true" />
162
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544142759655" />
161
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544154073764" />
163
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
162
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
164
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
163
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
165
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
164
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
176
       </list>
175
       </list>
177
     </option>
176
     </option>
178
   </component>
177
   </component>
179
-  <component name="RunManager" selected="JUnit.ArrazTest.test2FindMaxMinOfArray">
180
-    <configuration name="ArrazTest.test2FindMaxMinOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
178
+  <component name="RunManager" selected="JUnit.ArrazTest.test2Find2ndLargestValueFromArray">
179
+    <configuration name="ArrazTest.test2Find2ndLargestValueFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
181
       <module name="arraz" />
180
       <module name="arraz" />
182
       <option name="PACKAGE_NAME" value="" />
181
       <option name="PACKAGE_NAME" value="" />
183
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
182
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
184
-      <option name="METHOD_NAME" value="test2FindMaxMinOfArray" />
183
+      <option name="METHOD_NAME" value="test2Find2ndLargestValueFromArray" />
185
       <option name="TEST_OBJECT" value="method" />
184
       <option name="TEST_OBJECT" value="method" />
186
       <method v="2">
185
       <method v="2">
187
         <option name="Make" enabled="true" />
186
         <option name="Make" enabled="true" />
188
       </method>
187
       </method>
189
     </configuration>
188
     </configuration>
190
-    <configuration name="ArrazTest.test2InsertIntoArrayAt" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
189
+    <configuration name="ArrazTest.test2FindMaxMinOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
191
       <module name="arraz" />
190
       <module name="arraz" />
192
       <option name="PACKAGE_NAME" value="" />
191
       <option name="PACKAGE_NAME" value="" />
193
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
192
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
194
-      <option name="METHOD_NAME" value="test2InsertIntoArrayAt" />
193
+      <option name="METHOD_NAME" value="test2FindMaxMinOfArray" />
195
       <option name="TEST_OBJECT" value="method" />
194
       <option name="TEST_OBJECT" value="method" />
196
       <method v="2">
195
       <method v="2">
197
         <option name="Make" enabled="true" />
196
         <option name="Make" enabled="true" />
198
       </method>
197
       </method>
199
     </configuration>
198
     </configuration>
200
-    <configuration name="ArrazTest.test2RemoveElementFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
199
+    <configuration name="ArrazTest.test2RemoveDupesFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
201
       <module name="arraz" />
200
       <module name="arraz" />
202
       <option name="PACKAGE_NAME" value="" />
201
       <option name="PACKAGE_NAME" value="" />
203
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
202
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
204
-      <option name="METHOD_NAME" value="test2RemoveElementFromArray" />
203
+      <option name="METHOD_NAME" value="test2RemoveDupesFromArray" />
205
       <option name="TEST_OBJECT" value="method" />
204
       <option name="TEST_OBJECT" value="method" />
206
       <method v="2">
205
       <method v="2">
207
         <option name="Make" enabled="true" />
206
         <option name="Make" enabled="true" />
208
       </method>
207
       </method>
209
     </configuration>
208
     </configuration>
210
-    <configuration name="ArrazTest.testFindMaxMinOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
209
+    <configuration name="ArrazTest.testFind2ndLargestValueFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
211
       <module name="arraz" />
210
       <module name="arraz" />
212
       <option name="PACKAGE_NAME" value="" />
211
       <option name="PACKAGE_NAME" value="" />
213
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
212
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
214
-      <option name="METHOD_NAME" value="testFindMaxMinOfArray" />
213
+      <option name="METHOD_NAME" value="testFind2ndLargestValueFromArray" />
215
       <option name="TEST_OBJECT" value="method" />
214
       <option name="TEST_OBJECT" value="method" />
216
       <method v="2">
215
       <method v="2">
217
         <option name="Make" enabled="true" />
216
         <option name="Make" enabled="true" />
218
       </method>
217
       </method>
219
     </configuration>
218
     </configuration>
220
-    <configuration name="ArrazTest.testInsertIntoArrayAt" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
219
+    <configuration name="ArrazTest.testRemoveDupesFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
221
       <module name="arraz" />
220
       <module name="arraz" />
222
       <option name="PACKAGE_NAME" value="" />
221
       <option name="PACKAGE_NAME" value="" />
223
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
222
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
224
-      <option name="METHOD_NAME" value="testInsertIntoArrayAt" />
223
+      <option name="METHOD_NAME" value="testRemoveDupesFromArray" />
225
       <option name="TEST_OBJECT" value="method" />
224
       <option name="TEST_OBJECT" value="method" />
226
       <method v="2">
225
       <method v="2">
227
         <option name="Make" enabled="true" />
226
         <option name="Make" enabled="true" />
228
       </method>
227
       </method>
229
     </configuration>
228
     </configuration>
230
     <list>
229
     <list>
231
-      <item itemvalue="JUnit.ArrazTest.test2RemoveElementFromArray" />
232
-      <item itemvalue="JUnit.ArrazTest.testInsertIntoArrayAt" />
233
-      <item itemvalue="JUnit.ArrazTest.test2InsertIntoArrayAt" />
234
-      <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray" />
235
       <item itemvalue="JUnit.ArrazTest.test2FindMaxMinOfArray" />
230
       <item itemvalue="JUnit.ArrazTest.test2FindMaxMinOfArray" />
231
+      <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray" />
232
+      <item itemvalue="JUnit.ArrazTest.test2RemoveDupesFromArray" />
233
+      <item itemvalue="JUnit.ArrazTest.testFind2ndLargestValueFromArray" />
234
+      <item itemvalue="JUnit.ArrazTest.test2Find2ndLargestValueFromArray" />
236
     </list>
235
     </list>
237
     <recent_temporary>
236
     <recent_temporary>
238
       <list>
237
       <list>
238
+        <item itemvalue="JUnit.ArrazTest.test2Find2ndLargestValueFromArray" />
239
+        <item itemvalue="JUnit.ArrazTest.testFind2ndLargestValueFromArray" />
240
+        <item itemvalue="JUnit.ArrazTest.test2RemoveDupesFromArray" />
241
+        <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray" />
239
         <item itemvalue="JUnit.ArrazTest.test2FindMaxMinOfArray" />
242
         <item itemvalue="JUnit.ArrazTest.test2FindMaxMinOfArray" />
240
-        <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray" />
241
-        <item itemvalue="JUnit.ArrazTest.test2InsertIntoArrayAt" />
242
-        <item itemvalue="JUnit.ArrazTest.testInsertIntoArrayAt" />
243
-        <item itemvalue="JUnit.ArrazTest.test2RemoveElementFromArray" />
244
       </list>
243
       </list>
245
     </recent_temporary>
244
     </recent_temporary>
246
   </component>
245
   </component>
254
       <option name="number" value="Default" />
253
       <option name="number" value="Default" />
255
       <option name="presentableId" value="Default" />
254
       <option name="presentableId" value="Default" />
256
       <updated>1544046001151</updated>
255
       <updated>1544046001151</updated>
257
-      <workItem from="1544046022231" duration="18399000" />
256
+      <workItem from="1544046022231" duration="21160000" />
258
     </task>
257
     </task>
259
     <servers />
258
     <servers />
260
   </component>
259
   </component>
261
   <component name="TestHistory">
260
   <component name="TestHistory">
262
-    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 21m 09s.xml">
261
+    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 32m 40s.xml">
263
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
262
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
264
     </history-entry>
263
     </history-entry>
265
-    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 19h 22m 09s.xml">
264
+    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 21h 55m 22s.xml">
266
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
265
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
267
     </history-entry>
266
     </history-entry>
268
-    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 19h 23m 02s.xml">
267
+    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 21h 55m 58s.xml">
269
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
268
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
270
     </history-entry>
269
     </history-entry>
271
-    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 23m 30s.xml">
272
-      <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
273
-    </history-entry>
274
-    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 23m 50s.xml">
275
-      <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
270
+    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 21h 59m 30s.xml">
271
+      <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
276
     </history-entry>
272
     </history-entry>
277
-    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 19h 28m 37s.xml">
273
+    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 22h 10m 25s.xml">
278
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
274
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
279
     </history-entry>
275
     </history-entry>
280
-    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 28m 45s.xml">
276
+    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 22h 10m 33s.xml">
281
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
277
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
282
     </history-entry>
278
     </history-entry>
283
-    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 19h 30m 52s.xml">
284
-      <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
285
-    </history-entry>
286
-    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 19h 32m 29s.xml">
279
+    <history-entry file="ArrazTest_testFindMaxMinOfArray - 2018.12.06 at 22h 15m 48s.xml">
287
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
280
       <configuration name="ArrazTest.testFindMaxMinOfArray" configurationId="JUnit" />
288
     </history-entry>
281
     </history-entry>
289
-    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 19h 32m 40s.xml">
282
+    <history-entry file="ArrazTest_test2FindMaxMinOfArray - 2018.12.06 at 22h 15m 54s.xml">
290
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
283
       <configuration name="ArrazTest.test2FindMaxMinOfArray" configurationId="JUnit" />
291
     </history-entry>
284
     </history-entry>
285
+    <history-entry file="ArrazTest_testRemoveDupesFromArray - 2018.12.06 at 22h 31m 40s.xml">
286
+      <configuration name="ArrazTest.testRemoveDupesFromArray" configurationId="JUnit" />
287
+    </history-entry>
288
+    <history-entry file="ArrazTest_test2RemoveDupesFromArray - 2018.12.06 at 22h 32m 31s.xml">
289
+      <configuration name="ArrazTest.test2RemoveDupesFromArray" configurationId="JUnit" />
290
+    </history-entry>
292
   </component>
291
   </component>
293
   <component name="TimeTrackingManager">
292
   <component name="TimeTrackingManager">
294
-    <option name="totallyTimeSpent" value="18399000" />
293
+    <option name="totallyTimeSpent" value="21160000" />
295
   </component>
294
   </component>
296
   <component name="ToolWindowManager">
295
   <component name="ToolWindowManager">
297
-    <frame x="-332" y="-934" width="1636" height="793" extended-state="0" />
296
+    <frame x="0" y="159" width="1280" height="747" extended-state="0" />
298
     <editor active="true" />
297
     <editor active="true" />
299
     <layout>
298
     <layout>
300
       <window_info id="Image Layers" />
299
       <window_info id="Image Layers" />
302
       <window_info id="UI Designer" />
301
       <window_info id="UI Designer" />
303
       <window_info id="Capture Tool" />
302
       <window_info id="Capture Tool" />
304
       <window_info id="Favorites" side_tool="true" />
303
       <window_info id="Favorites" side_tool="true" />
305
-      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.072145544" />
304
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.09289176" />
306
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
305
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
307
-      <window_info anchor="bottom" id="Messages" weight="0.3259587" />
306
+      <window_info anchor="bottom" id="Messages" weight="0.32594937" />
308
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
307
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
309
       <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
308
       <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
310
-      <window_info anchor="bottom" id="Terminal" weight="0.3649289" />
309
+      <window_info anchor="bottom" id="Terminal" weight="0.3908228" />
311
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
310
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
312
       <window_info anchor="bottom" id="Message" order="0" />
311
       <window_info anchor="bottom" id="Message" order="0" />
313
       <window_info anchor="bottom" id="Find" order="1" />
312
       <window_info anchor="bottom" id="Find" order="1" />
314
-      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.40855458" />
313
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.40822786" />
315
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39810428" />
314
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39810428" />
316
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
315
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
317
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
316
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
363
     </entry>
362
     </entry>
364
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
363
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
365
       <provider selected="true" editor-type-id="text-editor">
364
       <provider selected="true" editor-type-id="text-editor">
366
-        <state relative-caret-position="550">
367
-          <caret line="197" column="16" lean-forward="true" selection-start-line="197" selection-start-column="16" selection-end-line="197" selection-end-column="16" />
365
+        <state relative-caret-position="94">
366
+          <caret line="108" column="18" selection-start-line="108" selection-start-column="18" selection-end-line="108" selection-end-column="18" />
368
           <folding>
367
           <folding>
369
-            <element signature="imports" expanded="true" />
368
+            <element signature="e#1659#1668#0" expanded="true" />
370
             <element signature="e#1375#1376#0" expanded="true" />
369
             <element signature="e#1375#1376#0" expanded="true" />
371
             <element signature="e#1410#1411#0" expanded="true" />
370
             <element signature="e#1410#1411#0" expanded="true" />
372
             <element signature="e#1454#1455#0" expanded="true" />
371
             <element signature="e#1454#1455#0" expanded="true" />
385
     </entry>
384
     </entry>
386
     <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
385
     <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
387
       <provider selected="true" editor-type-id="text-editor">
386
       <provider selected="true" editor-type-id="text-editor">
388
-        <state relative-caret-position="73">
389
-          <caret line="292" column="49" selection-start-line="292" selection-start-column="49" selection-end-line="292" selection-end-column="49" />
387
+        <state relative-caret-position="96">
388
+          <caret line="339" column="15" selection-start-line="339" selection-start-column="15" selection-end-line="339" selection-end-column="15" />
390
           <folding>
389
           <folding>
391
             <element signature="imports" expanded="true" />
390
             <element signature="imports" expanded="true" />
392
           </folding>
391
           </folding>

+ 33
- 10
arraz/src/main/java/Arraz.java View File

1
-import java.util.ArrayList;
2
-import java.util.Arrays;
3
-import java.util.Iterator;
4
-import java.util.List;
1
+import java.util.*;
5
 
2
 
6
 public class Arraz {
3
 public class Arraz {
7
 
4
 
90
         return arr;
87
         return arr;
91
     }
88
     }
92
 
89
 
90
+    public Integer[] removeDupesFromArray(Integer[] array) {
91
+        Set<Integer> list = new HashSet<Integer>();
92
+        int count = 0;
93
+
94
+        for (Integer i : array){
95
+            list.add(i);
96
+        }
97
+
98
+        int len = list.size();
99
+        Integer[] newArr = new Integer[len];
100
+
101
+        for (Integer i : list){
102
+            newArr[count] = i;
103
+            count++;
104
+        }
105
+
106
+        return newArr;
107
+    }
108
+
109
+    public Integer find2ndLargestValueFromArray(Integer[] array) {
110
+        if (array.length < 2){
111
+            return -1;
112
+        }
113
+
114
+        Integer[] arr = new Integer[array.length];
115
+                Arrays.sort(array);
116
+
117
+        return array[array.length - 2];
118
+    }
119
+
93
     public class OddEven {
120
     public class OddEven {
94
         public int odds;
121
         public int odds;
95
         public int evens;
122
         public int evens;
186
     public MaxMin findMaxMinOfArray(int[] array) {
213
     public MaxMin findMaxMinOfArray(int[] array) {
187
         MaxMin mn = new MaxMin();
214
         MaxMin mn = new MaxMin();
188
 
215
 
189
-        mn.max = array[0];
190
-        mn.min = array[0];
216
+        mn.setMax(array[0]);
217
+        mn.setMin(array[0]);
191
 
218
 
192
         for (int i : array){
219
         for (int i : array){
193
             if ( i > mn.getMax() ){
220
             if ( i > mn.getMax() ){
197
             if ( i < mn.getMin() ){
224
             if ( i < mn.getMin() ){
198
                 mn.setMin(i);
225
                 mn.setMin(i);
199
             }
226
             }
200
-
201
-            System.out.println("Max is: " + mn.max);
202
-            System.out.println("Min is: " + mn.min);
203
         }
227
         }
204
 
228
 
205
         return mn;
229
         return mn;
206
-
207
     }
230
     }
208
 }
231
 }

+ 46
- 3
arraz/src/test/java/ArrazTest.java View File

286
         int[] array = {1,5,2,4,3};
286
         int[] array = {1,5,2,4,3};
287
         int expected = 5;
287
         int expected = 5;
288
 
288
 
289
+        Arraz arraz = new Arraz();
289
         Arraz.MaxMin mn = arraz.new MaxMin();
290
         Arraz.MaxMin mn = arraz.new MaxMin();
290
 
291
 
291
         arraz.findMaxMinOfArray(array);
292
         arraz.findMaxMinOfArray(array);
292
 
293
 
293
-        Assert.assertEquals(expected, mn.getMax());
294
+        Assert.assertEquals(expected, arraz.findMaxMinOfArray(array).getMax());
294
 
295
 
295
     }
296
     }
296
 
297
 
300
         int[] array = {1,5,2,-1,0};
301
         int[] array = {1,5,2,-1,0};
301
         int expected = -1;
302
         int expected = -1;
302
 
303
 
304
+        Arraz arraz = new Arraz();
303
         Arraz.MaxMin mn = arraz.new MaxMin();
305
         Arraz.MaxMin mn = arraz.new MaxMin();
304
 
306
 
305
-        arraz.findMaxMinOfArray(array);
306
 
307
 
307
-        Assert.assertEquals(expected, mn.getMin());
308
+        Assert.assertEquals(expected, arraz.findMaxMinOfArray(array).getMin());
309
+
310
+    }
311
+
312
+    @Test
313
+    public void testRemoveDupesFromArray(){
314
+
315
+        Integer[] array = {1,2,3,2,4,4,5,6,7,7,8};
316
+
317
+        Integer[] expected = {1,2,3,4,5,6,7,8};
318
+        Integer[] actual = arraz.removeDupesFromArray(array);
319
+
320
+        Assert.assertEquals(expected, actual);
321
+    }
322
+
323
+    @Test
324
+    public void test2RemoveDupesFromArray(){
325
+
326
+        Integer[] array = {1,1,1,1,1,1,1,1};
327
+
328
+        Integer[] expected = {1};
329
+        Integer[] actual = arraz.removeDupesFromArray(array);
330
+
331
+        Assert.assertEquals(expected, actual);
332
+    }
333
+
334
+    @Test
335
+    public void testFind2ndLargestValueFromArray(){
336
+
337
+        Integer[] array = {1,2,3,4,5};
338
+
339
+        Integer expected = 4;
340
+        Integer actual = arraz.find2ndLargestValueFromArray(array);
308
 
341
 
342
+        Assert.assertEquals(expected, actual);
309
     }
343
     }
310
 
344
 
345
+    @Test
346
+    public void test2Find2ndLargestValueFromArray(){
347
+
348
+        Integer[] array = {1};
311
 
349
 
350
+        Integer expected = -1;
351
+        Integer actual = arraz.find2ndLargestValueFromArray(array);
352
+
353
+        Assert.assertEquals(expected, actual);
354
+    }
312
 }
355
 }