AlmostIncreasingSequence | CodeFights Intro Algorithm JavaScript Solution and Breakdown

AlmostIncreasingSequence | CodeFights Intro Algorithm JavaScript Solution and Breakdown
Support our Community:
-Code, Tech and Caffeine Facebook Group:
– Looking for a a Bootcamp check out DevMountain’s program where housing is included with the tuition:

Tutoring, Mentoring and Course Walkthroughs available:

Thank you to my Patreon Supporters Below:
-Check out

Support me and visit my store at:

Internship, Part-Time, & Full time work for college students and recent grads:

Fan funding goes towards buying the equipment necessary to deliver 4k videos, 4k webcam, and a high quality microphone better audio. Any support is very appreciated!

My channel is here for aspiring programmers to learn easier and help debug any issues from the many great free resources available on the web.

Check out my other videos going over HTML, CSS, Ruby, Ruby on Rails, Java, JavaScript, Python, PHP, SQL, Command Line, BootStrap, jQuery, and WordPress from CodeCademy, CodeCombat, FreeCodecamp and more!

Please watch: “How I Became a Developer | My Developer Journey of the Last 3 Years | Ask a Dev”



19 thoughts on “AlmostIncreasingSequence | CodeFights Intro Algorithm JavaScript Solution and Breakdown

  1. Maybe JavaScript is much different from Java, but just by looking at the code, you sure thing get out of bounds exceptions.

  2. Nice one;
    Couldn't put down a good logic statement to solve the problem;
    First few lines of the program outline seem to be a little bit the same;
    Nice one;

  3. I'm feeling bad, i've create all this code that not passed, and the solution is more simple than i think

    for(x=0; x<sequence.length; x++){
    var removedNum = sequence.splice(x, 1);
    console.log("New array: " + sequence.toString());
    console.log("Removed number: " + removedNum.toString());
    var count = 0;
    for(z=0; z<sequence.length-1; z++){
    if(parseInt(sequence[z]) >= parseInt(sequence[z+1])){
    console.log("Count: " + cont);
    return true;
    return false;

  4. here is my code for this particular problem, this code works with all the test case but it exceeded the execution time limit. kindly tell me how to reduce it

    ps: this code is in python

    def almostIncreasingSequence(sequence):

    for i in range(len(x)):
    del y[i]
    for j in range(len(y)):
    if j==len(y)-1:
    elif y[j] < y[j+1]:

    for i in state_list:
    if False not in i:
    return True
    return False

    your output will be most beneficial

  5. Solved this problem under 10 mins only to find that my program is not optimized enough to pass the time constraint checks in the last two tests. It almost took a day for me to again resolve it.

  6. instead of checking if it's sorted….why not just sort it by default….it's takes the same amount of code…am I wrong?

  7. I used a prototype 🙂

    let arr = [0,1,2,3,4,5,4]; = function(i) {
    return this[i] <= this[i+1];

    function isAlmostInc(arr) {
    var falseCount = 0;
    for (let i = 0; i < arr.length -1; i++) {
    if ( === false) falseCount++;
    return falseCount < 2;


  8. This problem got me, but I kept at it. my logic might be time consuming but hey I passed all the tests and that is what matters

Leave a Reply

Your email address will not be published. Required fields are marked *