Giter Site home page Giter Site logo

ishu9bansal / ideone Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 161 KB

useful pieces of codes

C++ 100.00%
algorithms algorithms-and-data-structures binary-search modulo-arithmetics inverse-modulo directions-algorithm directions-iterator kmp-algorithm print-tree lru-cache

ideone's Introduction

ideone

will incrementally contain all my ideone codes

usage

Each folder consists of a readme file and associated code file.

README file contains the description of the problem statement, solution approach and complexity.

It also contains the ideone link of the code which will mostly be in runnable state, with some sample inputs.

Check out a user friendly view here!

ideone's People

Contributors

ishu9bansal avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

emkay-git

ideone's Issues

Lazy segment tree

Implement a lazy segment tree, with update and query operations over a range.

Interval Intersection

Write an efficient method to insert an interval in a data structure and get all the ranges intersecting with a given range.
The runtime should be proportional to the size of the intersection result.

Pick indices

This is very similar to a filter array method. But this is much useful, with some added functionality. If we think the indices as pointers between the elements then it also gives us clear distinction when dealing with ranges in an array.

Use this submission as an example to set up something like this , and use something useful

https://leetcode.com/submissions/detail/1157513853/

Adding the code block for the same for faster code copying:

template <class T>
vector<int> pickIndices(const vector<T>& v, function<bool(const vector<T>&, int)> predicate) {
    vector<int> ans;
    for(int i=0; i<=v.size(); i++)
        if(predicate(v,i))
            ans.push_back(i);
    return ans;
}
bool isSorted(vector<int>& v) {
    vector<int> kinks = pickIndices<int>(v,
        [](const vector<int>& v, int i) -> bool {
               if(i>=v.size() || i<=0) return false;
               return v[i]<v[i-1];
           });
    return kinks.empty();
}

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.