Description
COMP2113 Programming Technologies
Module 7 Checkpoint Exercise
Name: Shaheer Ziya
Instructions:
For each single question or each group of questions in the Checkpoint exercise, please type your answer right after the question in this Word document.
Checkpoint 7.1 (Please submit your answer to Moodle)
ofstream cfile; cfile.open (c.txt, ios::ate, ios::binary); [Assuming the file c.txt exists.]
Ans: The method on file stream objects expects only 2 arguments, the file name and the open mode. In the code above two different open methods are provided. The std::ios::ate method moves the pointer to the end of the file immediately after opening while the std::ios::binary method ensures that text output to the file and input from the file is comparable.To correct this error, simply open the file with just one openmode (either ios::ate or ios::binary)
Checkpoint 7.2 (Please submit your answer to Moodle)
LeetCode is a popular and famous platform and community among developers over the world. It is a well-developed platform for challenging yourselves on coding skills as well as practising and preparing for interviews for the Tech Giant companies like Google, Microsoft, Facebook, etc.
Figure 1
Figure 2
After successful signup, please log in. You should be able to see the following page after login (Fig. 3). Choose Problem #1 (Title: Two Sum), and you will be brought to the problem description and a VPL-like online coding environment (Fig. 4).
Figure 3
Figure 4 Explore also the tabs “Solution”, “Submissions” and “Discuss”. In particular, under “Submission”, you will be able to find the information of your submissions (Fig. 5).
Figure 5
When you click on the status of each submission, you will be able to see the runtime (i.e., how fast your solution is) and the memory consumption. Also, you can see how your solution is ranked among other submission from all over the world in terms of runtime (Fig. 6). You can keep improving your solution in order to beat others!
Figure 6
Please complete Problem #1 (Title: Two Sum) and provide a screen capture (similar to that in Fig. 5) for your submission.
An example (vectorcode.cpp) for simple usage of vector is included for your reference.
Reviews
There are no reviews yet.