#242

Codeforces Round #242 (Div. 2) B

不羁的心 提交于 2021-02-08 06:37:49
question B. Megacity time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city. The city of Tomsk can be represented as point on the plane with coordinates ( 0 ; 0 ). The city is surrounded with n other locations, the i -th one has coordinates ( x i , y i ) with the population of k i people.

LeetCode:Valid Anagram

a 夏天 提交于 2019-12-15 20:25:43
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 1、题目名称 Valid Anagram (易位构词) 2、题目地址 https://leetcode.com/problems/valid-anagram/ 3、题目内容 英文:Given two strings s and t, write a function to determine if t is an anagram of s. 中文:给出两个字符串,写一个函数判断t是否是s的易位构词 例如: s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. 4、题目分析 易位构词游戏的规则可以参考相关的 维基百科页面 :易位构词是一类文字游戏。它的规则是将组成一个词或短句的字母重新排列顺序,原文中所有字母的每次出现都被使用一次,这样构造出另外一些新的词或短句。现在我们要判断的就是给出两个字符串s和t,判断字符串t能否由s通过易位构词产生。 5、一个超时的方法 在做这个题的时候我第一个想到的方法就是,将s和t两个字符串先转换成数组,然后分别对两个数组进行排序,再对两个排序后的数组进行逐位比较。如果发现两个数组中不一致的地方,则返回false,否则返回true。对应的Java代码如下: /** * 功能说明