adding old solved challenges
This commit is contained in:
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="accountSettings">
|
||||
<option name="activeRegion" value="us-east-1" />
|
||||
<option name="recentlyUsedRegions">
|
||||
<list>
|
||||
<option value="us-east-1" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/TallestCandle.iml" filepath="$PROJECT_DIR$/TallestCandle.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
package TallestCandle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class TallestCandles {
|
||||
public static void main(String[] args) {
|
||||
List<Integer> nums = new ArrayList<>();
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
System.out.println("How old are you?");
|
||||
int n = sc.nextInt();
|
||||
for (int i = 0; i < n; i++) {
|
||||
nums.add(sc.nextInt());
|
||||
}
|
||||
int x = tallestCandles(nums);
|
||||
System.out.println(x);
|
||||
sc.close();
|
||||
}
|
||||
|
||||
public static int tallestCandles(List<Integer> candles) {
|
||||
int tallestCandle = 0;
|
||||
int sumofTallestCandles = 0;
|
||||
|
||||
for (int num : candles) {
|
||||
if (num > tallestCandle) {
|
||||
tallestCandle = num;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < candles.size(); i++) {
|
||||
if (candles.get(i) == tallestCandle) {
|
||||
sumofTallestCandles++;
|
||||
}
|
||||
}
|
||||
return sumofTallestCandles;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user