This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def final_time(tasks, cooldown): | |
# this question is actually about putting a serialized tasks into parallel task Q | |
task_run_time = 1 | |
lastExcStart = {} # coreId:lastTask's Start Time | |
sim_time = 0 | |
for task in tasks: | |
if task not in lastExcStart: | |
# if no task is running on this core, init the queue with cuurent simTime | |
lastExcStart[task] = sim_time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def spiral_print(self, matrix): | |
seen = set() | |
action_seq = [(0, +1), (+1, 0), (0, -1), (-1, 0)] | |
act = 0 | |
curr = (0, 0) | |
seen.add(curr) | |
res = [] | |
res.append(matrix[curr[0]][curr[1]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_neighbors_4C(self, pt): | |
# put self.gird in your class private | |
x,y = pt[0], pt[1] | |
# x positive top down, Y to the right | |
maxX = len(self.grid) | |
maxY = len(self.grid[0]) | |
# define the neighbor pattern | |
nc4 = '[[x-1,y], [x+1,y], [x,y-1], [x,y+1]]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import rospy | |
import tf | |
from tf import transformations as ts | |
from geometry_msgs.msg import Transform, Vector3, Quaternion | |
from geometry_msgs.msg import TransformStamped | |
from std_msgs.msg import Header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ros/ros.h> | |
#include <tf2_ros/transform_listener.h> | |
#include <geometry_msgs/Transform.h> | |
#include <geometry_msgs/TransformStamped.h> | |
#include <tf/transform_broadcaster.h> | |
int main(int argc, char** argv){ | |
ros::init(argc, argv, "fix_tf_cpp"); | |
ros::NodeHandle node; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @brief Constructor for the wrapper | |
* @param name The name for this costmap | |
* @param tf A reference to a TransformListener | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct A | |
{ | |
int data[2]; | |
A(int x, int y) : data{x, y} {} | |
virtual void f() {} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/* | |
* Class template identification | |
*/ | |
using namespace std; | |
template<typename D, typename B> | |
class IsDerivedFromHelper | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
/***********************************************/ | |
/* @Task: combination | |
* @Input: n: number range 1 to n; k is number takes | |
* @Return: list of lists | |
* @Example: leetcode 8.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <climits> | |
struct TreeNode { | |
int val; | |
TreeNode* left; | |
TreeNode* right; | |
TreeNode(int x): val(x), left(nullptr), right(nullptr) {} | |
}; |
NewerOlder