LeetCode summary, leetcode

Source: Internet
Author: User
Tags multiply strings what interface

LeetCode summary, leetcode
Some of our common basic data structures, such as integer int or floating point float, cannot be stored with built-in data because of too many digits. At this time, we need to implement high-precision data types for storage and computation. This problem is more practical in actual products, so it is also a frequent visitor in the interview. In LeetCode, there are the following high-precision questions:
Add Binary
Add Two Numbers
Plus One
Multiply Strings

Add Binary and Add Two Numbers are of the same type. They are both high-precision addition operations, but they are Binary and decimal. In fact, the hexadecimal mode does not matter, the code can basically be implemented in a unified way. The idea is also very simple, that is, adding from the low position and maintaining the carry. It is a very basic array operation, and there is no algorithm difficulty, mainly look at the coding implementation capability.

Plus One is also a common question. It is actually the ++ operator in C ++, because only + 1 is needed, so it is actually easier than the above question. The small trap of this question is that it uses Arrays for storage from high to low. Therefore, if carry occurs, you need to re-allocate the space and assign 1 to the highest bit, assign 0 to other bits. Here, we just introduced a point that high-precision storage should be low to high-level storage or vice versa, which is also a question that may be asked during the interview.

Multiply Strings is a high-precision Multiplication operation. It is complicated and requires calculation and accumulation of the results of each bit. There are a lot of details here, I personally think the implementation is a little complicated and not very suitable for the interview.

Although there are not many questions, the issue of such questions is very high. The main reason is not that such questions have many test sites, but that they are very well extended. Basically, they ask such questions, the first step is to examine the coding capability. Generally, this is the addition, subtraction, multiplication, and division operation. Next we will definitely look at the design of the data structure (or object-oriented. These questions are all for the high-precision BigInteger service. The interviewer will ask some questions about the data structure design. For example, if you want to design this class, what data structures are used for storage (such as arrays or linked lists), what interfaces (constructor, addition, subtraction, multiplication, division, and so on), and how to design constructor, what interface constructor is required (here, the value assignment constructor and the value assignment operator are required. However, you must provide interfaces for general types such as int and long, A good high-precision class must be compatible with its weaker data structure ). I have listed some questions that may be further examined during the interview, which is also a part of Lenovo. It is also very common to ask many questions about such design, you can prepare and think about this issue on your own.
What is leetcode?

There are many programming and interview questions, which can be compiled and run online. It is difficult. If you can do it all by yourself, it is very helpful for large companies. I just did the questions there.

C ++ returns a string? Why have I tested both dev c ++ and vc60? But cannot it be used in leetcode?

The Runtime Error does not mean that your program cannot be compiled, but that your program encountered an Error during running. This error is generally caused by out-of-bounds array access, stack overflow, and illegal memory access.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.