ChatCrawlersearch across public Telegram Open the app
C

Coding Tree

сообщение · 2023-04-22 12:42 UTC
L
Problem Statement 18: Prakhar has a strings of length n containing only characters "J"L" and "R". He wants to find the length of the smallest substring, which satisfies the following condition: Length of the substring is at least 2 'J' occurs strictly more times in this substring than 'L'. 'J' occurs strictly more times in this substring than 'R' Prakhar is busy planning designs in Jaguar F-Pace, help him solve the problem. A substring is a contigudus sequence of characters within a string. Constraints: length of string s is n and 2 <= n <= 10^6 Input: The first line contains the length of strings i.en Second line contains the strings consisting only letters "", "L" and "R" Output: print in a single line the length of the smallest substring which satisfies all the above conditions. output-1 if there is no such substring. Sample Test Case 1: Input: 2 JJ Expected Output: 2 Sample Test Case 2: Input: 8 Expected Output: 3 Sample Test Case 3: Input: 5 RLJLL Expected Output: -1

Вся лента · оригинал в Telegram

Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog