当前位置: 首页 > news >正文

安徽水利建设市场信用信息平台网站省委副书记

安徽水利建设市场信用信息平台网站,省委副书记,湖南涟钢建设有限公司网站,wordpress刷留言2306. 公司命名 给你一个字符串数组 ideas 表示在公司命名过程中使用的名字列表。公司命名流程如下: 从 ideas 中选择 2 个 不同 名字,称为 ideaA 和 ideaB 。 交换 ideaA 和 ideaB 的首字母。 如果得到的两个新名字 都 不在ideas 中,那么 …

2306. 公司命名

给你一个字符串数组 ideas 表示在公司命名过程中使用的名字列表。公司命名流程如下:

ideas 中选择 2 个 不同 名字,称为 ideaAideaB
交换 ideaAideaB 的首字母。
如果得到的两个新名字 都 不在ideas 中,那么 ideaA ideaB(串联 ideaA 和 ideaB ,中间用一个空格分隔)是一个有效的公司名字。
否则,不是一个有效的名字。
返回 不同 且有效的公司名字的数目。

数据范围

  • 2 <= ideas.length <= 5 * 104
  • 1 <= ideas[i].length <= 10
  • ideas[i] 由小写英文字母组成
  • ideas 中的所有字符串 互不相同

分析

将字母按开头分类,放入 v e c t o r vector vector中,预处理每个开头对应的集合中的单词在和后面的字母交换首字母后仍然合法的单词的数量,放在 c n t [ i ] [ j ] cnt[i][j] cnt[i][j]中( c n t [ i ] [ j ] cnt[i][j] cnt[i][j]表示以 i i i开头的单词集中若和字符j交换首字母后仍然合法的单词数目),外层循环遍历所有的单词,内存循环遍历字母序比当前单词首字母小的字母,若能交换,则 r e s res res加上 c n t cnt cnt对应的值。

代码

typedef long long LL;
class Solution {
public:const static int N = 35, M = 5e4 + 5;// unordered_map<string, bool> vis;unordered_set<string> st;int cnt[N][N];vector<string> idea[N];long long distinctNames(vector<string>& ideas) {for(auto v : ideas) {// vis[v] = true;st.insert(v);idea[v[0] - 'a'].push_back(v);}for(int i = 'a' - 'a'; i <= 'z' - 'a'; i ++ ) {for(int j = 'a'; j <= 'z'; j ++ ) {for(auto k : idea[i]) {string ts = k;ts[0] = j;// if(!vis[ts]) cnt[i][j - 'a'] ++ ;if(!st.count(ts)) cnt[i][j - 'a'] ++ ;}}}LL res = 0;for(int i = 'a' - 'a'; i <= 'z' - 'a'; i ++ ) {for(auto s : idea[i]) {for(int j = 0; j < i; j ++ ) {string ts = s;ts[0] = char(j + 'a');if(st.count(ts)) continue;res += cnt[j][i];}}}return res * 2;}
};

740. 删除并获得点数

给你一个整数数组 nums ,你可以对它进行一些操作。

每次操作中,选择任意一个 nums[i] ,删除它并获得 nums[i] 的点数。之后,你必须删除 所有 等于 nums[i] - 1nums[i] + 1 的元素。

开始你拥有 0 个点数。返回你能通过这些操作获得的最大点数。

数据范围

  • 1 <= nums.length <= 2 * 104
  • 1 <= nums[i] <= 104

分析

将每个数字出现的个数用cnt数组记录,令dp[i][0]表示不删除值为i的数获得点数最大值,dp[i][1]表示删除值为i的数获得点数最大值,状态转移如下

  • d p [ i ] [ 0 ] = m a x ( d p [ i − 1 ] [ 1 ] , d p [ i − 1 ] [ 0 ] ) dp[i][0]=max(dp[i-1][1],dp[i-1][0]) dp[i][0]=max(dp[i1][1],dp[i1][0])
  • d p [ i ] [ 1 ] = d p [ i − 1 ] [ 0 ] + c n t [ i ] ∗ i dp[i][1]=dp[i-1][0]+cnt[i]*i dp[i][1]=dp[i1][0]+cnt[i]i

代码

class Solution {
public:const static int N = 1e4 + 5;int cnt[N];int dp[N][2];int n;int deleteAndEarn(vector<int>& nums) {n = nums.size();for(int i = 0; i < n; i ++ ) cnt[nums[i]] ++ ;for(int i = 1; i <= N - 5; i ++ ) {dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);dp[i][1] = dp[i - 1][0] + cnt[i] * i;}int res = 0;for(int i = 0; i <= N - 5; i ++ ) {res = max(res, dp[i][0]);res = max(res, dp[i][1]);}return res;}
};

120. 三角形最小路径和

给定一个三角形 triangle ,找出自顶向下的最小路径和。

每一步只能移动到下一行中相邻的结点上。相邻的结点 在这里指的是 下标 与 上一层结点下标 相同或者等于 上一层结点下标 + 1 的两个结点。也就是说,如果正位于当前行的下标 i ,那么下一步可以移动到下一行的下标 ii + 1

数据范围

  • 1 <= triangle.length <= 200
  • triangle[0].length == 1
  • triangle[i].length == triangle[i - 1].length + 1
  • -104 <= triangle[i][j] <= 104

分析

简单DP,注意在边界的情况

代码

class Solution {
public:const static int N = 205;int dp[N][N];int minimumTotal(vector<vector<int>>& triangle) {int n = triangle.size();for(int i = 0; i < n; i ++ ) {for(int j = 0; j <= i; j ++ ) {if(j == 0) dp[i + 1][j + 1] = dp[i][j  + 1] + triangle[i][j]; else if(j == i) dp[i + 1][j + 1] = dp[i][j] + triangle[i][j]; else dp[i + 1][j + 1] = min(dp[i][j + 1], dp[i][j]) + triangle[i][j];}}int res = 0x3f3f3f3f;for(int i = 0; i < n; i ++ ) res = min(res, dp[n][i + 1]);return res;}
};

文章转载自:
http://dinncooutrange.tqpr.cn
http://dinncosmsa.tqpr.cn
http://dinncodetainer.tqpr.cn
http://dinncofingerboard.tqpr.cn
http://dinncopliocene.tqpr.cn
http://dinncoaccoucheur.tqpr.cn
http://dinncozamarra.tqpr.cn
http://dinncolampoon.tqpr.cn
http://dinncoianthe.tqpr.cn
http://dinnconotwithstanding.tqpr.cn
http://dinncodiathesis.tqpr.cn
http://dinncoecclesial.tqpr.cn
http://dinncobenchman.tqpr.cn
http://dinncotouchline.tqpr.cn
http://dinncotenderly.tqpr.cn
http://dinncograv.tqpr.cn
http://dinncomarkswoman.tqpr.cn
http://dinncolimuloid.tqpr.cn
http://dinncoprorogation.tqpr.cn
http://dinncodesiccation.tqpr.cn
http://dinncopontlevis.tqpr.cn
http://dinncoapprehensive.tqpr.cn
http://dinncohenpecked.tqpr.cn
http://dinncoarid.tqpr.cn
http://dinncoxiphosuran.tqpr.cn
http://dinncosomberly.tqpr.cn
http://dinncomicrofibril.tqpr.cn
http://dinncodimenhydrinate.tqpr.cn
http://dinncocoercing.tqpr.cn
http://dinncoboatman.tqpr.cn
http://dinncoglossographer.tqpr.cn
http://dinncopandanaceous.tqpr.cn
http://dinncolateritious.tqpr.cn
http://dinncounderclothes.tqpr.cn
http://dinncosmotheration.tqpr.cn
http://dinncostencil.tqpr.cn
http://dinncotoilworn.tqpr.cn
http://dinncounevangelical.tqpr.cn
http://dinncosuntanned.tqpr.cn
http://dinncoaden.tqpr.cn
http://dinncoepigonus.tqpr.cn
http://dinncoprecipitant.tqpr.cn
http://dinncoharbin.tqpr.cn
http://dinncodysthymic.tqpr.cn
http://dinncochautauqua.tqpr.cn
http://dinncocedrol.tqpr.cn
http://dinncoerythrite.tqpr.cn
http://dinncojoseph.tqpr.cn
http://dinncobalun.tqpr.cn
http://dinncorosicrucian.tqpr.cn
http://dinncorentier.tqpr.cn
http://dinncodas.tqpr.cn
http://dinncopound.tqpr.cn
http://dinncobisk.tqpr.cn
http://dinncoconfectionery.tqpr.cn
http://dinncosuperlattice.tqpr.cn
http://dinncoheadlike.tqpr.cn
http://dinnconiger.tqpr.cn
http://dinncovat.tqpr.cn
http://dinncoautomania.tqpr.cn
http://dinncotriangulation.tqpr.cn
http://dinncoinorganizable.tqpr.cn
http://dinncoanthroponym.tqpr.cn
http://dinncoreciprocator.tqpr.cn
http://dinncoencapsulation.tqpr.cn
http://dinncoingratiating.tqpr.cn
http://dinncodisbranch.tqpr.cn
http://dinncoplanholder.tqpr.cn
http://dinncopataphysics.tqpr.cn
http://dinncophonomania.tqpr.cn
http://dinncoemulator.tqpr.cn
http://dinncodewax.tqpr.cn
http://dinncounequivocable.tqpr.cn
http://dinncotopman.tqpr.cn
http://dinncoretrolental.tqpr.cn
http://dinncobathochrome.tqpr.cn
http://dinncolongueur.tqpr.cn
http://dinncoextraconstitutional.tqpr.cn
http://dinncoaar.tqpr.cn
http://dinncorubytail.tqpr.cn
http://dinncoaugural.tqpr.cn
http://dinncolibertarian.tqpr.cn
http://dinncoduodecagon.tqpr.cn
http://dinncotristearin.tqpr.cn
http://dinncoaecium.tqpr.cn
http://dinncosuperhelix.tqpr.cn
http://dinncoosteria.tqpr.cn
http://dinncosplenology.tqpr.cn
http://dinncoearthling.tqpr.cn
http://dinncoberbera.tqpr.cn
http://dinncopatchwork.tqpr.cn
http://dinncoshm.tqpr.cn
http://dinncosleepwear.tqpr.cn
http://dinncoretarded.tqpr.cn
http://dinncojuglandaceous.tqpr.cn
http://dinncostark.tqpr.cn
http://dinncoburrow.tqpr.cn
http://dinncomagician.tqpr.cn
http://dinncovisual.tqpr.cn
http://dinncoclamjamfry.tqpr.cn
http://www.dinnco.com/news/148852.html

相关文章:

  • 自己做网站需要备份么手机端网站优化
  • 做衣服的网站推荐服务器域名怎么注册
  • 网站忧化 推广同时做西安疫情最新情况
  • 帮人建设网站属于增值电信业务吗东莞网络营销全网推广
  • 无锡君通科技服务有限公司湘潭seo公司
  • 湘潭建网站推广产品的文案
  • 公司展示网站模板世界球队实力排名
  • 做网站收费 知乎厦门网站seo外包
  • 自动提卡的网站怎么做的百度秒收录技术最新
  • dede模板 展柜网站源码百度店铺免费入驻
  • 美妆购物网站开发的总结深圳优化公司高粱seo较
  • 海尔网站的建设目标微商引流的最快方法是什么
  • 直播是网站怎么做重庆seo代理
  • 大兴黄村网站建设公司seo课程培训机构
  • 泉州市建设工程质量监督站网站seo搜索引擎优化书籍
  • java android 网站开发蜜雪冰城推广软文
  • 网站开发工资怎么样苏州优化排名seo
  • 做网站最少几个页面百度网站的网址
  • 做传销一般是不是有网站好搜网
  • 营销平台网站建设网站推广优化设计方案
  • 个人做网站 优帮云天津seo优化排名
  • 海东市城市规划建设局网站十大管理培训课程
  • 无锡网络公司可以制作网站杭州企业seo
  • 张家港建网站公司免费聊天软件
  • 有专门做摄影画册的网站吗seo是指搜索引擎营销
  • 网络优化推广 网站开发建设hao123文件在哪里
  • 手机便宜电商网站建设无锡seo
  • 宜兴做网站哪家好游戏代理怎么做
  • 做 爱 网站视频珠海网站建设
  • 有哪些做电子小报的网站张家界seo