随笔分类 - 数据结构
摘要:Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume t
阅读全文
摘要:A parentheses string is valid if and only if: It is the empty string, It can be written as AB (A concatenated with B), where A and B are valid strings
阅读全文
摘要:Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linea
阅读全文
摘要:给定一个整数数组,判断是否存在重复元素。 如果存在一值在数组中出现至少两次,函数返回 true 。如果数组中每个元素都不相同,则返回 false 。 题解一:双循环 class Solution { public boolean containsDuplicate(int[] nums) { for
阅读全文