Leetcode Hacking Practice -- Solution in C++ Part 5
文章內容
LeetCode (used to call i has 1337 code) is a social platform for preparing IT technical interviews. We strive to provide you with the best learning experience in preparing interviews for companies in the IT industry.
To be successful in a technical interview, we believe it is mainly repeating these three important steps:
Code. Read. Discuss.
We strive to provide you the LeetCode platform as the ultimate solution for preparing technical interviews.
1. Code -> Code solution using the Online Judge system.
2. Read -> Read high quality article featuring in-depth thought process. Also read other LeetCoders’ code.
3. Discuss -> Discuss your thoughts about the problem with other LeetCoders.
We hope that through our platform, you will grow into a LeetCoder. Not only will you be successful in all of your interviews, and most importantly, you will be a better coder in general !
This is Part 5 (第五部分)
第一部分: www.westca.com/Forums/...inese.html
第二部分: www.westca.com/Forums/...inese.html
第三部分: www.westca.com/Forums/...inese.html
第四部分: www.westca.com/Forums/...inese.html
To be successful in a technical interview, we believe it is mainly repeating these three important steps:
Code. Read. Discuss.
We strive to provide you the LeetCode platform as the ultimate solution for preparing technical interviews.
1. Code -> Code solution using the Online Judge system.
2. Read -> Read high quality article featuring in-depth thought process. Also read other LeetCoders’ code.
3. Discuss -> Discuss your thoughts about the problem with other LeetCoders.
We hope that through our platform, you will grow into a LeetCoder. Not only will you be successful in all of your interviews, and most importantly, you will be a better coder in general !
This is Part 5 (第五部分)
第一部分: www.westca.com/Forums/...inese.html
第二部分: www.westca.com/Forums/...inese.html
第三部分: www.westca.com/Forums/...inese.html
第四部分: www.westca.com/Forums/...inese.html
分享: |
![]() |
文章評論
webdriver | 無題 2014-09-25 00:29:19 | 引用 |
無題 推薦答案來了 (in C++) ...
back-tracking..
2014-09-25 00:31:00 | 引用 |
webdriver |
webdriver | 無題 算法問題: Sum Root to Leaf Numbers
問題描述: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \ 2 3 The root-to-leaf path 1->2 represents the number 12. The root-to-leaf path 1->3 represents the number 13. Return the sum = 12 + 13 = 25. 2014-09-25 00:32:50 | 引用 |
無題 推薦答案來了 (in C++) ...
1. Recursion (add to sum when reaching the leaf). 2. Iterative solution.
2014-09-25 00:33:00 | 引用 |
webdriver |
webdriver | 無題 算法問題: Surrounded Regions
問題描述: Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region . For example, X X X X X O O X X X O X X O X X After running your function, the board should be: X X X X X X X X X X X X X O X X 2014-09-25 00:33:20 | 引用 |
無題 推薦答案來了 (in C++) ...
Traverse from the boarder to the inside and mark all the 'O's that are not surrounded by 'X' as 'V' (visited). 1. DFS. 2. BFS (queue).
2014-09-25 00:33:31 | 引用 |
webdriver |
webdriver | 無題 算法問題: Swap Nodes in Pairs
問題描述: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. 2014-09-25 00:33:51 | 引用 |
無題 推薦答案來了 (in C++) ...
1. Iterative solution with constant space. 2. Recursive solution with O(n) space (for practice).
2014-09-25 00:34:01 | 引用 |
webdriver |
webdriver | 無題 算法問題: Symmetric Tree
問題描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following is not: 1 / \ 2 2 \ \ 3 3 Note: Bonus points if you could solve it both recursively and iteratively. 2014-09-25 00:34:41 | 引用 |
無題 推薦答案來了 (in C++) ...
1. Recursive solution 2.Iterative way (queue).
2014-09-25 00:35:01 | 引用 |
webdriver |
問題描述:
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.