Skip to content

Instantly share code, notes, and snippets.

@mfigueroa
mfigueroa / rotateRight.py
Created March 13, 2022 02:55
Rotate List
# https://leetcode.com/problems/rotate-list/
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def rotateRight(self, head, k):
"""
:type head: ListNode
@mfigueroa
mfigueroa / bfs.cpp
Last active May 6, 2018 01:20
Find Number of Nodes for a Given Level Using BFS
/**
* Title: Solution for Level Nodes Problem on HackerEarth
* Author: Manuel Figueroa (github.com/mfigueroa)
*
* Breadth First Search: https://www.hackerearth.com/practice/algorithms/graphs/breadth-first-search/tutorial/
*
* Problem Summary
* You have been given a Tree consisting of N nodes. A tree is a fully-connected graph consisting of N nodes and N - 1 edges.
* The nodes in this tree are indexed from 1 to N. Consider node indexed 1 to be the root node of this tree. The root
* node lies at level one in the tree. You shall be given the tree and a single integer x. You need to find out the