Skip to content

Commit

Permalink
add problem 20 valid parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelarian committed Mar 8, 2024
1 parent 38e98ef commit 936f021
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ValidParentheses/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions ValidParentheses/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ValidParentheses/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions ValidParentheses/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.miguelvela</groupId>
<artifactId>ValidParentheses</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
7 changes: 7 additions & 0 deletions ValidParentheses/src/main/java/com/miguelvela/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.miguelvela;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
38 changes: 38 additions & 0 deletions ValidParentheses/src/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Valid Parentheses (20)

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Every close bracket has a corresponding open bracket of the same type.


## Example 1

```java
Input: s = "()"
Output: true
```

## Example 2

```java
Input: s = "()[]{}"
Output: true
```

## Example 3

```java
Input: s = "(]"
Output: false
```

## Constraints:

```
1 <= s.length <= 104
s consists of parentheses only '()[]{}'.
```

0 comments on commit 936f021

Please sign in to comment.