Skip to content

Instantly share code, notes, and snippets.

@JeongB-L
Created November 2, 2021 12:16
Show Gist options
  • Save JeongB-L/6312a562581778d23bf8e20aed747a5c to your computer and use it in GitHub Desktop.
Save JeongB-L/6312a562581778d23bf8e20aed747a5c to your computer and use it in GitHub Desktop.
leetcodeFiles
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="true" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/examplar.iml" filepath="$PROJECT_DIR$/examplar.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="bc67c3f7-8fc7-4c7d-a439-a8b353c73a94" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="ProjectId" id="20GTsUdlSsfNa28r0iZHYa5yB8m" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="org.jetbrains.plugins.github.ui.GithubSettingsConfigurable" />
</component>
<component name="RunManager" selected="Application.SumOfOneDArray">
<configuration name="GoalParser" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="GoalParser" />
<module name="examplar" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="SumOfOneDArray" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="SumOfOneDArray" />
<module name="examplar" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.SumOfOneDArray" />
<item itemvalue="Application.GoalParser" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="bc67c3f7-8fc7-4c7d-a439-a8b353c73a94" name="Default Changelist" comment="" />
<created>1635670135032</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1635670135032</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="208" y="31" key="#Project_Structure" timestamp="1635670148510">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="208" y="31" key="#Project_Structure/[email protected]" timestamp="1635670148510" />
<state x="440" y="259" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1635673856108">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="440" y="259" key="#com.intellij.fileTypes.FileTypeChooser/[email protected]" timestamp="1635673856108" />
<state width="1398" height="304" key="GridCell.Tab.0.bottom" timestamp="1635674271280">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.0.bottom/[email protected]" timestamp="1635674271280" />
<state width="1398" height="304" key="GridCell.Tab.0.center" timestamp="1635674271277">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.0.center/[email protected]" timestamp="1635674271277" />
<state width="1398" height="304" key="GridCell.Tab.0.left" timestamp="1635674271276">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.0.left/[email protected]" timestamp="1635674271276" />
<state width="1398" height="304" key="GridCell.Tab.0.right" timestamp="1635674271279">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.0.right/[email protected]" timestamp="1635674271279" />
<state width="1398" height="304" key="GridCell.Tab.1.bottom" timestamp="1635674271285">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.1.bottom/[email protected]" timestamp="1635674271285" />
<state width="1398" height="304" key="GridCell.Tab.1.center" timestamp="1635674271282">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.1.center/[email protected]" timestamp="1635674271282" />
<state width="1398" height="304" key="GridCell.Tab.1.left" timestamp="1635674271281">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.1.left/[email protected]" timestamp="1635674271281" />
<state width="1398" height="304" key="GridCell.Tab.1.right" timestamp="1635674271284">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state width="1398" height="304" key="GridCell.Tab.1.right/[email protected]" timestamp="1635674271284" />
<state x="229" y="89" key="SettingsEditor" timestamp="1635855358746">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="229" y="89" key="SettingsEditor/[email protected]" timestamp="1635855358746" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/SumOfOneDArray.java</url>
<line>9</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
public class GoalParser {
public static String interpret(String command) {
//replace every () into o, using replace() function.
//replace every ( and ) into nothing using replace() function.
// return the finale
String finale = "";
String newCommand = command.replace("()", "o");
newCommand = newCommand.replace("(", "");
finale = newCommand.replace(")", "");
return finale;
}
public static void main(String[]args) {
String example = "G()()()(al)";
interpret(example);
}
}
public class Operations {
public int finalValueAfterOperations(String[] operations) {
int x = 0;
for (int i = 0; i < operations.length; i++) {
if (operations[i].equals("X++") || operations[i].equals("++X")) {
x++;
} else if (operations[i].equals("X--") || operations[i].equals("--X")) {
x--;
}
}
/*int X = 0;
for (String operation : operations) {
if (operation.contains("++")) X++;
if (operation.contains("--")) X--;
}
*/
return x;
}
}
public class SumOfOneDArray {
//use for loop
//keep the sum
//add the previous some to the new value and then store it into the finale array.
public static int[] runningSum(int[] nums) {
int[] finale = new int[nums.length];
finale[0] = nums[0];
int sum = finale[0];
for (int i = 1; i < nums.length; i++) {
sum += nums[i];
finale[i] = sum;
//System.out.println(finale[i]);
}
return finale;
}
public static void main(String[]args) {
int[] array = new int[4];
array = new int[]{1, 2, 3, 4};
runningSum(array);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment