checkcheckzz / coding-questions Goto Github PK
View Code? Open in Web Editor NEWCoding interview questions with solutions (deprecated)
Home Page: http://itgeekworkhard.com/coding-questions/
Coding interview questions with solutions (deprecated)
Home Page: http://itgeekworkhard.com/coding-questions/
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 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
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
I came across 2 problem in your approach:
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;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.