原创 C語言筆試面試總結(網上搜集)

1.關鍵字static的作用是什麼? 有三個明顯的作用: 1)在函數體內,一個被聲明爲靜態的變量在這個函數被調用過程中維持其值不變 2)在模塊內(但在函數體外),靜態的變量可以被模塊內所有函數訪問,但不能被模塊外其他函數訪問 3)在模塊內

原创 Binary Tree Right Side View

問題Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see or

原创 Populating Next Right Pointers in Each Node

問題Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode

原创 Perfect Squares

1.問題描述 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) whi

原创 Populating Next Right Pointers in Each Node II

問題Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree?

原创 Binary Tree Maximum Path Sum

問題Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from som

原创 Kth Smallest Element in a BST

問題Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assum

原创 Symmetric Tree

問題Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this bina

原创 Path Sum

問題Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along

原创 (c++)——內聯函數

首先,內聯函數通常是較小的函數,但是爲什麼要提出使用它呢? 我們的代碼通常需要一些共同的操作,但是,當需要進行對此修改呢,這時就需要沒一個修改, 可以想到將此操作定義成函數,但是新的問題又出現了,函數的話必須進行函數調用,調用的 過程是保

原创 預編譯命令

預編譯:在真正編譯之前設置一些變量,環境設置。 主要的命令有 #define——宏定義:文本替換,不能提供變量類型檢查,還有需要主要宏定義函數時, 結合順序有時候發生變化。#if #elif #else #endif 可以實現代碼的分塊執

原创 Validate Binary Search Tree

問題Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The lef

原创 Unique Binary Search Trees II

問題Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n =

原创 Sort List

1.問題描述 Sort a linked list in O(n log n) time using constant space complexity. 鏈表排序。 2.解答 /** * Definition for singly-l

原创 Path Sum II

問題Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: G