个人简介

Echo Blog


江湖无名 安心练剑
  • leetcode 139 word break 回溯 backtrack
    题目 Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the diction...
    2020-01-23 02:09:32 | Algorithm
  • leetcode 135 Candy 递归+MEM
    题目 There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requireme...
    2020-01-23 02:09:32 | Algorithm
  • leetcode 131 Palindrome Partitioning 动态规划/回溯 DP/backtrack
    题目 131 描述 Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example 1: Input: s = "aab" Output: [["a...
    2020-01-23 02:09:32 | Algorithm
  • leetcode 123 Best Time to Buy and Sell Stock III 动态规划
    题目 You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete at most two transactions. Note: You may ...
    2020-01-23 02:09:32 | Algorithm
  • leetcode 115 Distinct Subsequences 动态规划
    题目 Given two strings s and t, return the number of distinct subsequences of s which equals t. The test cases are generated so that the answer fits on a 32-bit signed integer. 例子 Example 1: Inp...
    2020-01-23 02:09:32 | Algorithm
  • 面试算法:前 K 个高频元素详解汇总
    前 K 个高频元素 题目 给定一个非空的整数数组,返回其中出现频率前 k 高的元素。 示例 1: 输入: nums = [1,1,1,2,2,3], k = 2 输出: [1,2] 示例 2: 输入: nums = [1], k = 1 输出: [1] 提示: 你可以假设给定的 k 总是合理的,且 1 ≤ k ≤ 数组中不相同的元素的个数。 你的...
    2020-01-23 02:09:32 | Data-Struct
  • 面试算法:如何找到数组中出现次数最多的元素?
    多数元素 题目 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊ n/2 ⌋ 的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 示例 1: 输入:[3,2,3] 输出:3 示例 2: 输入:[2,2,1,1,1,2,2] 输出:2 进阶: 尝试设计时间复杂度为 O(n)、空间复杂度为 O(1) 的算...
    2020-01-23 02:09:32 | Data-Struct
  • 面试算法:数字 1 的个数
    题目 给定一个整数 n,计算所有小于等于 n 的非负整数中数字 1 出现的个数。 示例 1: 输入:n = 13 输出:6 示例 2: 输入:n = 0 输出:0 提示: 0 <= n <= 2 * 10^9 暴力法 思路 直接遍历所有的数字,统计 1 出现的次数。 java 实现 /** * 最基本的思路: * * 直接统计各个...
    2020-01-23 02:09:32 | Data-Struct