0%

Problem 20: Valid Parentheses

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

An input string is valid if:

  1. Open brackets must be closed by the same type of brackets.
  2. Open brackets must be closed in the correct order.

Note that an empty string is also considered valid.

阅读全文 »

笔者理工科在读研究生,从高中开始嗜读科普读物,开始参加化学竞赛,与自然科学结下不解之缘。本科专业方向金属加工相关,也由于项目原因接触过能源材料相关课题(锂电、电催化),同时多次参加创新创业项目及数学建模竞赛,结识了不少不同专业的同学。因此笔者斗胆认为,相对于同龄人,本人还是具有较强的跨学科意识的,习惯于进入新的(研究)领域。

阅读全文 »

Problem 821: Shortest Distance to a Character

Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.

Example 1:

1
2
Input: S = "loveleetcode", C = 'e'
Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]

Note:

  1. S string length is in [1, 10000].
  2. C is a single character, and guaranteed to be in string S.
  3. All letters in S and C are lowercase.
阅读全文 »