GithubHelp home page GithubHelp logo

prep's People

Contributors

juchem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prep's Issues

given a sorted sequence and an integer N, generate all sorted subsequences with size N

#include <iostream>
#include <type_traits>
#include <iterator>
#include <vector>

using namespace std;

template<typename T>
void genseq(T start, T end, int tam);

int main()
{
    char master[] = {'a','b','c','d','e'};
    for( int s = 0; s <= 6; ++s ) {
        genseq(master,master+5,s);
    }
}

// need one n sized subsequence starting at each element of the master sequence
// n sized subsequences starting in X are X + all n-1 sized subsequences after X
// a 0 sized subsequence defines its ending
// n sized subsequences starting in X when there are less than n-1 elements 
after X are discarded

template<typename T>
void genseq2(T start, T end, int tam, vector<typename 
iterator_traits<T>::value_type> & seq)
{
    if( tam == 0 ) {
        // emit seq and return
        copy(seq.begin(),seq.end(),ostream_iterator<typename iterator_traits<T>::value_type>(cout,","));
        cout << endl;
        return;
    }

    for( T x = start; x != end-tam+1; ++x ) {
        seq.push_back(*x);
        genseq2(x+1,end,tam-1,seq);
        seq.pop_back();
    }
}

template<typename T>
void genseq(T start, T end, int tam)
{
    cout << "generating sequences for size " << tam << endl;
    if( tam <= 0 || end-start < tam ) return;

    vector<typename iterator_traits<T>::value_type> seq;
    genseq2(start, end, tam, seq);
}

Original issue reported on code.google.com by [email protected] on 20 Jul 2012 at 4:46

Bug in the solution to measure the perimter of a skyline

What steps will reproduce the problem?

1.
Input:
0 4 1
1 1 1
2 1 2

What is the expected output? What do you see instead?
The result should be: 8
The actual result is:  10

Version:
http://ideone.com/oYg0Fq

Please provide any additional information below.
It looks like there's a bug while removing the element from the bst when two or 
more elements have the same height

Original issue reported on code.google.com by vdeantoni on 25 Mar 2013 at 7:28

exercise 10

int treeSum(TreeNode * node) {
    if( ! node ) return 0;

    return node->value += treeSum(node->left) + treeSum(node->right);
}

Original issue reported on code.google.com by [email protected] on 13 Jul 2012 at 6:15

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.