Atlast done it fully
$categories = get_the_category($post->ID);
foreach($categories as $category) :
$children = get_categories( array ('parent' => $category->term_id ));
$category_link = get_category_link($children);
$has_children = count($children);
if ( $has_children == 0 ) {
$name=$category->name;
$category_link = get_category_link($category);
echo "<a href="https://wordpress.stackexchange.com/questions/161873/$category_link">$name</a>";
}
endforeach;