GithubHelp home page GithubHelp logo

Hi šŸ‘‹, I'm Jibendu Paul

A passionate frontend developer from India

jibendu007

jibendu007

jibendu99

Connect with me:

jibendu99 jibendu paul rivu_krivu jibendu_paul jibenu_paul FrozT#3698

Languages and Tools:

cplusplus css3 git html5 javascript mysql nodejs opencv python react scikit_learn

jibendu007

Ā jibendu007

jibendu007

Jibendu Paul's Projects

longest-weird-subsequence icon longest-weird-subsequence

Finding the longest increasing subsequence is an old and well-known problem now. Here you will have to do something similar. You need to find the longest weird subsequence (LWS) of the given string. The subsequence is called weird if it can be split into two disjoint subsequences, one of which is non-decreasing and the other one is non-increasing. Just for clarity, by subsequence of the given string S we mean any string that can be obtained from S by erasing from it zero or more characters. So empty string is a subsequence of any string and any string is a subsequence of itself. Further, note that we consider only strings composed of lowercase Latin letters and these letters compared by their ASCII codes. So, for example, 'a' is smaller than 'b' and 'p' is larger than 'h'. Now let's consider some example. Let S="aabcazcczba". Then "abczz" is its some non-decreasing subsequene, "zccb" is its some non-increasing subsequence and "aabczcczba" is its some weird subsequence since it can be split into non-decreasing subsequence "aabzz" and non-increasing subsequence "cccba": "AABcZccZba" (first subsequence is shown by capital letters just for calrity). Input The first line contains a single positive integer T, the number of test cases. T test cases follow. The only line of each test case contains a non-empty string S composed of lowercase Latin letters. Output For every test case, output the length of the LWS of the given string. Constraints 1<= T <= 10 1 <= length of S <= 2000 Explanation First case: The string itself is LWS since it can be split into non-decreasing subsequence "abc" and non-increasing empty subsequence. Second case: One of the possible LWS is "cbaabc" since it can be split as "cbaABC". Here we indicate by capital letters non-decreasing subsequence and by lowercase letters non-increasing one. Other possible LWS's are "cbaZZa", "AzyaBC". Third case: Here the desired splitting is "ddAABBaaCC".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.