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. [JS奇怪的世界]No.55 危險小叮嚀:陣列與for in

    前言 前面已經瞭解了使用內建函數建構子的某些危險地方,但其實陣列與for in,也是有一些危險的地方. 陣列與for in 在前面幾個章節有講過陣列就是物件,所以我們一樣可以使用 for in來做處理 ...

  2. Android中JNI的使用方法(转载)

    Android中JNI的使用方法 首先看一下Android平台的框架图:(网上盗用) 可以看到Android上层的Application和ApplicationFramework都是使用Java编写, ...

  3. 「知乎」对中国用户而言,Pure Android 是否比 MIUI 或 Flyme 体验更好? - Donnie的博客

    这篇文章转载自我在知乎上的回答 哎呀-不要站队嘛.其实这是一个很有意思的题目,让我们一点点来看 哦对,谢妖-.本人是Nexus 5用户,系统当然是Pure Android KitKat啦(臭谷粉!点D ...

  4. 基于均值坐标(Mean-Value Coordinates)的图像融合算法的具体实现

    目录 1. 概述 2. 实现 2.1. 准备 2.2. 核心 2.2.1. 均值坐标(Mean-Value Coordinates) 2.2.2. ROI边界栅格化 2.2.3. 核心实现 2.2.4 ...

  5. 前端每日实战:147# 视频演示如何用纯 CSS 创作透视按钮的悬停特效

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qJEdKb 可交互视频 此视频是可 ...

  6. PC端如何下载B站里面的视频?

    此随笔只是记录一下:   PC端下载B站的视频,在blibli前面加上一个i 然后在视频上鼠标右键,视频另存为+路径即可 PS:网上其他的方法,比如在blibli前面加上kan,后面加上jj等,这些方 ...

  7. 数据分析你需要知道的操作:ETL和ELT

    如果您接触过数据仓库, 您可能会使用 ETL (Extract. Transform. Load) 或 ELT ( Extract.Load. Transform) 将您的数据从不同的来源提取到数据仓 ...

  8. 简单易懂的Servlet路径问题

    关于servlet路径,我看了一下网上别人的博客园,发现都有一个通病,讲的太专业了,又抓不住关键部分,往往看一眼就不想看第二眼.所以我特地准备了初学者所通识的servlet路径问题. 1.标识符 /j ...

  9. 并发工具类的使用 CountDownLatch,CyclicBarrier,Semaphore,Exchanger

    1.CountDownLatch 允许一个或多个线程等待直到在其他线程中执行的一组操作完成的同步辅助. A CountDownLatch用给定的计数初始化. await方法阻塞,直到由于countDo ...

  10. JAVA 16bit CRC_CCITT

    JAVA 16bit CRC_CCITT public class CRC_CCITT { static int CRC16_ccitt_table[] = { 0x0000, 0x1189, 0x2 ...