Giter Club home page Giter Club logo

coding-questions's People

Contributors

checkcheckzz avatar evilegg 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coding-questions's Issues

[Delete k digits] Possible Bug

Hello!,

I tried to use the code for deleting k digits but it seems it fails in some test cases.

Given num = 891, k =1.
Output 89

I think the correct solution is 81 instead. I've a similar code to get the min/max number by removing k digits, this will return the correct solution.

Please let me know if i'm missing something here.

Thanks

finish other coding qs

finish the problem in this repo: graph from links, Eulerian path, change return program. credit card validator, dijkstra’s algorithm , count words in a string, factor finder, coin flip simulation, closest pair problem

to finish the following coding problem

spreadsheet, Cover board with tile, Divide integers, Pizza picking problem, Boggle puzzle, Kth element in two sorted arrays, Celebrity problem, Recover the queue, Number of closed rectangles in a matrix, Check whether a tree exists, Trim binary search tree, Flip a binary tree, Climb ladder, Flip bits, Pair with largest common words, Reverse index search

Calculate (m^n)%(10^k)

I don't know how big you expect m to be, but if m is an int, n is long long and k is int - there's no need for simulating a big number via a string (also, there are better ways to create big numbers).

The solution code can be

long long get_m_to_nth_mod_10_to_kth(int m, long long n, int k)
{
    long long exponent = std::pow(10L, k);
    if (n == 1)
        return m % exponent;
    if (n%2) //odd
        return (get_m_to_nth_mod_10_to_kth(m,n-1,k) * m) % exponent;
    else
        return  static_cast<long long>(std::pow(get_m_to_nth_mod_10_to_kth(m,n/2,k), 2L)) % exponent;
    
}

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.