zoukankan      html  css  js  c++  java
  • 模拟面试001

    1.Linux中fork()的用途是什么

    通过复制调用进程来创建一个新进程。

    2.简单说一下你的这个视频流媒体服务器的项目

    3.

    题目描述

    给定一棵二叉搜索树,请找出其中的第k小的结点。
    示例1

    输入

    复制
    {5,3,7,2,4,6,8},3

    返回值

    复制
    {4}
    

    说明

    按结点数值大小顺序第三小结点的值为4 
    题目连接:https://www.nowcoder.com/practice/ef068f602dde4d28aab2b210e859150a
     1 /*
     2 struct TreeNode {
     3     int val;
     4     struct TreeNode *left;
     5     struct TreeNode *right;
     6     TreeNode(int x) :
     7             val(x), left(NULL), right(NULL) {
     8     }
     9 };
    10 */
    11 class Solution {
    12 public:
    13     TreeNode* KthNode(TreeNode* pRoot, int k)
    14     {
    15         if(pRoot == NULL || k == 0)
    16             return nullptr;
    17         return KthNodeCore(pRoot, k);
    18     }
    19     TreeNode* KthNodeCore(TreeNode* pRoot, int& k)
    20     {
    21         TreeNode* target = nullptr;
    22         if(pRoot->left != nullptr)
    23             target = KthNodeCore(pRoot->left, k);
    24         
    25         if(target == nullptr)
    26         {
    27             if(k == 1)
    28                 target = pRoot;
    29             else
    30                 k--;
    31         }
    32         
    33         if(target == nullptr && pRoot->right != nullptr)
    34             target = KthNodeCore(pRoot->right, k);
    35         
    36         return target;
    37     }
    38     
    39 };
    
    
    
    
    
  • 相关阅读:
    leetcode-409
    leetcode-836
    leetcode-1160
    leetcode-面试题13
    leetcode-695
    go的一些小lib
    leetcode-300
    cookie
    php上传文件
    PHP 文件创建/写入
  • 原文地址:https://www.cnblogs.com/wenzhixin/p/14164488.html
Copyright © 2011-2022 走看看