problem 1160. Find Words That Can Be Formed by Characters solution class Solution { public: int countCharacters(vector<string>& words, string chars) { ; unordered_map<char, int> charmap; for(auto ch:chars) charmap[ch]++; for(auto word:word…
题目如下: You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be used once). Return the sum of lengths of all good strings in words. Example 1: Input: words =…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典统计 日期 题目地址:https://leetcode-cn.com/problems/index-pairs-of-a-string/submissions/ 题目描述 You are given an array of strings words and a string chars. A string is good if it can be…
Difficulty: Hard  More:[目录]LeetCode Java实现 Description Given a string S, find the length of the longest substring T that contains at most two distinct characters.For example,Given S = “eceba”,T is "ece" which its length is 3. Intuition 方法一:假设有一个…
http://poj.org/problem?id=1160 题意:直线上有n个城市,其中有p个城市有邮局,问如何建p个邮局使得每个城市到最近的邮局和最小.(n<=300, p<=30&p<=n) #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <iostream> using namespace st…
DP. #include <stdio.h> #include <string.h> #include <stdlib.h> #define MAXNUM 1005 typedef struct { int w, s; int index; } mouse_st; mouse_st mouses[MAXNUM]; int dp[MAXNUM], next[MAXNUM]; int comp(const void *a, const void *b) { mouse_st…
problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完…
problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binary Numbers; 完…
problem 1025. Divisor Game 参考 1. Leetcode_easy_1025. Divisor Game; 完…
problem 1029. Two City Scheduling 参考 1. Leetcode_easy_1029. Two City Scheduling; 完…