Coder Social home page Coder Social logo

arc-arnob / daily-coding-practice Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 167.48 MB

Daily Coding Practice. Wanna learn together? Just fork this and let the PRs flow! We'll review it together!

JavaScript 36.43% Java 1.84% C++ 10.83% TypeScript 29.15% Kotlin 0.06% Swift 0.65% Objective-C 0.02% Dart 5.47% CMake 8.83% C 0.67% HTML 4.03% CSS 0.75% Ruby 1.26%
c daily-coding-problem java javascript

daily-coding-practice's Introduction

daily-coding-practice's People

Contributors

arc-arnob avatar mayank-m-sharma avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

daily-coding-practice's Issues

Help me find the bug

const printPermutation = (originalString, permutedStrings) => {
    if(originalString.length === 0){
        console.log(permutedStrings);
        return;
    }
    for(i in originalString){
        const firstChar = originalString[i];
        const remainingString =originalString.substring(0, i) + originalString.substring(i + 1);
        printPermutation(remainingString, permutedStrings + firstChar);
    }

}

printPermutation("abc", "");

https://bigfrontend.dev/problem/implement-basic-debounce

Debounce is a common technique used in Web Application, in most cases using lodash solution would be a good choice.

could you implement your own version of basic debounce()?

In case you forgot, debounce(func, delay) will returned a debounced function, which delays the invoke.

Here is an example.

Before debouncing we have a series of calling like

─A─B─C─ ─D─ ─ ─ ─ ─ ─E─ ─F─G

After debouncing at wait time of 3 dashes

─ ─ ─ ─ ─ ─ ─ ─ D ─ ─ ─ ─ ─ ─ ─ ─ ─ G

notes

please follow above spec. the behavior might not be exactly the same as lodash.debounce()

because window.setTimeout and window.clearTimeout are not accurate in browser environment, they are replaced to other implementation when judging your code. They still have the same interface, and internally keep track of the timing for testing purpose.

Find the bug

    getAllSubsequence(str) {

        /**
         * Expectation:
         * f(abc): '', a, b, c, ab, bc, ca, abc
         * Here at each recursion level each element
         * can decide to join the subset or not
         */
        console.log("Started: ", str);
        // Base Case
        if(str.length === 0) {
            const baseCaseResult = [];
            baseCaseResult.push[""];
            return baseCaseResult;
        }

        // get the first element in consideration
        const ch = str[0];
        // get the reamining string
        const remainingString = str.substring(1);
        console.log("Remaining subsr: ", remainingString);
        const recursion_result = this.getAllSubsequence(remainingString);

        const result = [];

        for(let i in recursion_result){
            console.log('I is: ', i);
            result.push(i);
        }

        for(let i in recursion_result){
            console.log('I is: ', i);
            result.push( ch + i);
        }
        console.log("Returning: ", result);
        return result;        

    }
}

const getSS = new Solution();

console.log(getSS.getAllSubsequence('abc'));```

MUST REVISE

console.log(JSON.stringify([1, 2, null, 3])) // "[1,2,null,3]"
console.log(JSON.stringify([1, 2, undefined, 3])) // "[1,2,null,3]"
console.log(null === undefined) // false
console.log(null == undefined) // true
console.log(null == 0)// false
console.log(null < 0)//false ???
console.log(null > 0) // false
console.log(null <= 0) // true???
console.log(null >= 0)// true
console.log(undefined == 0) // false
console.log(undefined < 0) // false
console.log(undefined > 0) // false
console.log(undefined <= 0) // false
console.log(undefined >= 0) // false

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.