Developing Code
Creating a Branch and Cloning a Repository
Developers need to develop code for new requirements based on the develop-dev branch.
- Open the req-demo project and choose Code > Repo from the navigation pane to access CodeArts Repo.
- Click the repo-demo repository.
- Open the local Git Bash, and run the following command to clone the develop-dev branch to the local PC:
git clone -b Branch name https:example.com
In the preceding command, Branch name indicates the name of the branch to be cloned, and https:example.com indicates the HTTPS address of the code repository.
If the following information is displayed, the develop-dev branch of the code repository repo-demo has been successfully cloned to the local PC:$ git clone -b develop-dev https://test.com/bb5f2eb7ded44e0bbc0ff4bd3d1d244c/repo-demo.git Cloning into 'repo-demo'... remote: Enumerating objects: 36, done. remote: Counting objects: 100% (36/36), done. remote: Compressing objects: 100% (30/30), done. remote: Total 36 (delta 0), reused 36 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (36/36), 301.74 KiB | 1.23 MiB/s, done.
Coding
- In the upper left corner of CodeArts IDE, choose to open the created code repository repo-demo.
- In the input box, enter the following information and click
: A path in a binary tree is defined as a node sequence, with an edge exists between every two adjacent nodes in the sequence. A node can appear only once in a path. The path must contain at least one node and does not necessarily pass through the root node. The path sum is the sum of the values of all nodes in the path. Based on this project, provide the root node of a binary tree, and return the maximum path sum. If you have any questions, feel free to ask me.
- After the code is generated, enter the following information, compile and run the verification script using Java and javac, and click the send icon
. Write a verification script and use Java and javac to compile and run it.
- After the code is generated, choose Terminal > New Terminal in the navigation pane and run the following command:
powershell -ExecutionPolicy Bypass -File run-tests.ps1In the preceding command, replace run-tests.ps1 with the script file to be run. In this document, the script file name is run-tests.ps1.
If the following information is displayed, the code can run properly.========================================== Maximum Path Sum in a Binary Tree - Test and Verification ========================================== [PASS] example1 [1,2,3] => 6 [PASS] example2 [-10,9,20,null,null,15,7] => 42 [PASS] allNegative [-1,-2,-3] => -1 [PASS] leftSkewedTree [5,4,null,3,null,2] => 14 [PASS] negativeBranchesIgnored [2,-1,-2] => 2 [PASS] complexTree => 1 =========================================== Results: 9 passed, 0 failed =========================================== All tests are passed.
The actual command output prevails.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot