{{ message }}

Instantly share code, notes, and snippets.

🎯
Focusing

# Zaur Fataliyevzziz

🎯
Focusing
Created Sep 26, 2018
Binary Tree traversal in C++
View binary-tree-traversal.cpp
 // Pre-order traversal /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */
Last active Sep 10, 2018
C++ floor and ceil one-liner
View floor-ceil.cpp
 double floor(double x){ return (x >= 0) ? (int) x : (x == (int) x ? x : (int) x - 1); } double ceil(double x){ return (x >= 0) ? ((x == (int) x) ? (int) x : (int) x + 1) : ((x == (int) x) ? (int) x + 1 : (int) x); }
Created Aug 23, 2018
Python formatted print
View py-formatted-print.md
`print("Dave have {} pens.".format(5))`
``````Dave have 5 pens.
``````
Last active Aug 14, 2018
Alternative to C++ to_string if not available in platform. It happens :)
View to_str.cpp
 std::string to_str(int num){ std::string str = ""; std::string nums[10]; nums[0] = "0"; nums[1] = "1"; nums[2] = "2"; nums[3] = "3"; nums[4] = "4"; nums[5] = "5"; nums[6] = "6"; nums[7] = "7"; nums[8] = "8"; nums[9] = "9"; if(num == 0) return nums[0]; int d = pow(10, 1.0 + floor(log10(num))); while (d /= 10) str += nums[(num / d) % 10];
You can’t perform that action at this time.