1
0

2017.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "../structs/Tree.h"
  2. #include <queue>
  3. using namespace std;
  4. void reversechild(TreeNode *root)
  5. {
  6. TreeNode *head = root;
  7. queue<TreeNode *> q;
  8. q.push(head);
  9. while (!q.empty())
  10. {
  11. head = q.front();
  12. q.pop();
  13. if (head->left)
  14. {
  15. q.push(head->left);
  16. }
  17. if (head->right)
  18. {
  19. q.push(head->right);
  20. }
  21. swap(head->left, head->right);
  22. }
  23. }
  24. #include <unordered_map>
  25. #include <vector>
  26. using namespace std;
  27. unordered_map<int, int> statistic(vector<int> L1)
  28. {
  29. unordered_map<int, int> m;
  30. for (auto i : L1)
  31. {
  32. m[i] = m[i] + 1;
  33. }
  34. return m;
  35. }
  36. #include "../structs/List.h"
  37. ListNode *integrateList(LitNode *L1, ListNode *l2)
  38. {
  39. ListNode *head = L1->value < L2->value ? L1 : L2;
  40. if (L1->value < L2->value)
  41. {
  42. L1 = L1->next;
  43. }
  44. else
  45. {
  46. L2 = L2->next;
  47. }
  48. ListNode *temp = head->next;
  49. while (L1 && L2)
  50. {
  51. temp->next = L1->value < L2->value ? L1 : L2;
  52. if (L1->value < L2->value)
  53. {
  54. L1 = L1->next;
  55. }
  56. else
  57. {
  58. L2 = L2->next;
  59. }
  60. temp = temp->next;
  61. }
  62. if(L1){
  63. temp->next = L1;
  64. }
  65. if(L2){
  66. temp->next = L2;
  67. }
  68. return head;
  69. }
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。