2020-02-03 20:43:46

问题描述

问题求解

    public boolean canTransform(String start, String end) {
int n = start.length();
List<int[]> s = new ArrayList<>();
List<int[]> e = new ArrayList<>();
for (int i = 0; i < n; i++) {
char c = start.charAt(i);
if (c == 'L' || c == 'R') {
s.add(new int[]{c - 'a', i});
}
c = end.charAt(i);
if (c == 'L' || c == 'R') {
e.add(new int[]{c - 'a', i});
}
}
if (s.size() != e.size()) return false;
for (int i = 0; i < s.size(); i++) {
int[] cs = s.get(i);
int[] ce = e.get(i);
if (cs[0] != ce[0]) return false;
if (cs[0] == 'L' - 'a' && cs[1] < ce[1]) return false;
if (cs[0] == 'R' - 'a' && cs[1] > ce[1]) return false;
}
return true;
}

  

Reverse Subarray To Maximize Array Value的更多相关文章

  1. 数学-绝对值-Reverse Subarray To Maximize Array Value

    2020-02-11 12:01:21 问题描述: 问题求解: 本题的难度个人感觉还是蛮大的,主要是不容易想到O(n)的解. 对于 ...a, [b, ... , c], d, ...,如果我们将其中 ...

  2. Get the largest sum of contiguous subarray in an int array

    When I finished reading this problem,I thought I could solve it by scanning every single subarray in ...

  3. [array] leetcode - 53. Maximum Subarray - Easy

    leetcode - 53. Maximum Subarray - Easy descrition Find the contiguous subarray within an array (cont ...

  4. 152. Maximum Product Subarray (Array; DP)

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  5. 53. Maximum Subarray (Array; DP)

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  6. array题目合集

    414. Third Maximum Number 给一个非空的整数数组,找到这个数组中第三大的值,如果不存在,那么返回最大的值.要求时间复杂度为o(n) 例如: Example 1: Input: ...

  7. CodeForces-1155D Beautiful Array

    Description You are given an array \(a\) consisting of \(n\) integers. Beauty of array is the maximu ...

  8. Educational Codeforces Round 63 D. Beautiful Array

    D. Beautiful Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. [Educational Codeforces Round 63 ] D. Beautiful Array (思维+DP)

    Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds ...

随机推荐

  1. Java NIO-09-零拷贝之 DMA

    DMA 的好处 在介绍DMA之前我想问大家:我们为什么要引入DMA,DMA对我们有什么好处那? 计算机系统中各种常用的数据输入/输出方法有查询方式(包括无条件及条件传送方式)和中断方式,这些方式适用于 ...

  2. 教你如何去除电脑QQ聊天窗口上的广告?

    当打开QQ聊天窗口时,就如下图一样各种广告不停地闪啊闪的,我没强迫症但是我也不喜欢看. 像咱们这些没有钱开会员又不喜欢整天看电脑QQ聊天窗口上的广告的"穷人们".那该咋办呢?好了, ...

  3. 查看网卡信息 - ethtool

    查看网卡是千兆还是万兆网卡,使用ethtool 网络接口名 ethtool eth0

  4. 【ThinkPHP6:从TP3升级到放弃】1. 前言及准备工作

    春节期间因为疫情的关系出不去门,所以就研究了一下ThinkPHP的最新版本6.0.2, 自己写了一个博客程序. 现在, 打算写一个ThinkPHP6的专题, 用来把自己在写博客的过程中入过的坑和获得的 ...

  5. CentOS7 安装python 3.5 及 pip安装

    1.CentOS7 安装Python 的依赖包 # yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-d ...

  6. 一位资深程序员大牛推荐的Java技术学习路线图

    Web应用,最常见的研发语言是Java和PHP. 后端服务,最常见的研发语言是Java和C/C++. 大数据,最常见的研发语言是Java和Python. 可以说,Java是现阶段中国互联网公司中,覆盖 ...

  7. lnmp 一键安装包(nginx) 运行laravel项目显示该网页无法正常运行

    vi /usr/local/nginx/conf/fastcgi.conf 注释掉 PHP_ADMIN_VALUE #fastcgi_param PHP_ADMIN_VALUE "open_ ...

  8. 石油测井专题(六)MCM工艺在LWD的应用

    在上一篇的MCM工艺我们提到过石英挠性加速度计的伺服电路采用此工艺可以有效提高仪器产品的稳定性和寿命. MCM相对于印制电路板(PCB)来讲,MCM技术采用了更短的连接长度和更紧密的器件布局,从而降低 ...

  9. sublime Text3 前端常用插件

    sublime Text3 前端常用插件 - File Switching (文件切换) --- Sublime Text提供了一个非常快速的方式来打开新的文件.只要按下Ctrl+ P并开始输入你想要 ...

  10. 使用CSS实现折叠面板总结

    任务目的 深入理解html中radio的特性 深入理解CSS选择器以及伪元素的使用 任务描述 使用input的radio单选框特性结合CSS中的伪元素实现bootstrap中折叠面板(点击查看样例), ...