原创 LeetCode | 113. Path Sum II

  題外話:又到了一月一度的coding time!   題目: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equal

原创 LeetCode | 118. Pascal s Triangle

  題目: Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's triangle, eac

原创 LeetCode | 115. Distinct Subsequences

  題目: Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of

原创 Pytorch | Pytorch框架中模型和數據的gpu和cpu模式:model.to(device), model.cuda(), model.cpu(), DataParallel

  背景介紹 我們在使用Pytorch訓練時,模型和數據有可能加載在不同的設備上(gpu和cpu),在算梯度或者loss的時候,報錯信息類似如下: RuntimeError: Function AddBackward0 returned

原创 LeetCode | 111. Minimum Depth of Binary Tree

  題目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path fro

原创 LeetCode | 109. Convert Sorted List to Binary Search Tree

  題目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For

原创 LeetCode | 112. 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 a

原创 LeetCode | 108. Convert Sorted Array to Binary Search Tree

  題目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this proble

原创 Package | OpenCV C++ cv::Mat 數據類型type對應的輸出值

  背景: 在使用OpenCV C++包時,通常需要訪問和修改cv::Mat的數據值。要做到點對點的處理,保證程序的正確性,需要先確定cv::Mat的數據類型type,以確定後續訪問cv::Mat數據的調用接口。   做法: 要確定cv:

原创 Package | Windows10 CUDA10.2 JDK8 環境下安裝NVidia Visual Profiler(nvvp)安裝Bug筆記

  背景 最近需要具體分析CUDA程序的GPU佔用情況。除了使用常見的clock、gettimeofday計時分析程序的效率之外,還可以使用nvidia推出的nvprof進行具體的GPU指令耗時分析,爲了方便分析,可以使用nvidia v

原创 LeetCode | 99. Recover Binary Search Tree

  題目: Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structur

原创 LeetCode | 100. Same Tree

  題目: 第100題啦!新的一年,多多刷題呀~   Given two binary trees, write a function to check if they are the same or not. Two binary tr

原创 LeetCode | 106. Construct Binary Tree from Inorder and Postorder Traversal

  題目: Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates

原创 C/C++ | ubuntu perf輔助分析程序瓶頸,查看程序佔用cpu情況

  背景:在分析C/C++程序運行耗時的時候,我們通常可以簡單地分段打印時間去分析程序地佔用耗時。ubuntu環境下還有更直觀且實用的工具perf,performance analysis tool,即性能分析工具,可以在進程運行時,記錄

原创 LeetCode | 102. Binary Tree Level Order Traversal

  題目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by lev