Elmagnifico's Blog

云深不知归处

LeetCode Solution(Easy.45-48)

c/c++,python,for work

45.Remove Nth Node From End of List Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. Afte...

LeetCode Solution(Easy.41-44)

c/c++,python,for work

41.Valid Sudoku Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A par...

LeetCode Solution(Easy.37-40)

c/c++,python,for work

37.Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 37...

LeetCode Solution(Easy.33-36)

c/c++,python,for work

33.Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#...

LeetCode Solution(Easy.29-32)

c/c++,python,for work

29.Plus One Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 29.Plus ...

LeetCode Solution(Easy.25-28)

c/c++,python,for work

25.Remove Element Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn’t matter what you leave beyond ...

LeetCode Solution(Easy.21-24)

c/c++,python,for work

21.Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 21.Climbi...

LeetCode Solution(Easy.17-20)

c/c++,python,for work

17.Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 i...

LeetCode Solution(Easy.13-16)

c/c++,python,for work

13.Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11’ has binary r...

LeetCode Solution(Easy.9-12)

c/c++,python,for work

9.Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return ...