commit d5703d1554710e7ceda6b0e10d6edfdf6b67c85e
parent 93e048ec42fa5029dc96c8fbea108dae70d9a74b
Author: AndrewLockVI <andrewlaack1@gmail.com>
Date: Sat, 4 Jan 2025 02:34:27 -0600
Did another
Diffstat:
2 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/binary-tree-level-order-traversal/trav.cpp b/binary-tree-level-order-traversal/trav.cpp
@@ -0,0 +1,51 @@
+// runtime: beats 100%
+// memory: beats 62.88%
+
+
+/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode() : val(0), left(nullptr), right(nullptr) {}
+ * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
+ * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
+ * };
+ */
+class Solution {
+public:
+ vector<vector<int>> levelOrder(TreeNode* root) {
+ vector<TreeNode*> nodes;
+ vector<vector<int>> retLs;
+
+ if(root != nullptr){
+ nodes.push_back(root);
+ }
+
+ int itr = 0;
+ while(!nodes.empty()){
+ vector<int> ls;
+ retLs.push_back(ls);
+ int count = nodes.size();
+
+ for(int i = 0; i < count; ++i){
+ TreeNode* current = nodes[0];
+ nodes.erase(nodes.begin());
+ retLs[itr].push_back(current->val);
+
+ if(current->left != nullptr){
+ nodes.push_back(current->left);
+ }
+
+ if(current->right != nullptr){
+ nodes.push_back(current->right);
+ }
+ }
+
+ itr += 1;
+ }
+
+ return retLs;
+ }
+};
diff --git a/max-dotproduct-of-subsequences/MaxDotProductOfTwoSubsequences.py b/max-dotproduct-of-subsequences/MaxDotProductOfTwoSubsequences.py
@@ -0,0 +1,14 @@
+
+# Call again with subset of set and input is selections
+def maxDotProduct(nums : list[int], nums2 : list[int]) -> int:
+ return 1
+
+
+def printResult(expected, actual):
+ print("EXP: " + str(actual))
+ print("ACTUAL: " + str(expected))
+
+
+printResult(18, maxDotProduct([2,1,-1,5], [3,0,-6]))
+printResult(21, maxDotProduct([3,-2] , [2,-6,7]))
+printResult(-1, maxDotProduct([-1,-1], [1,1]))