Elmagnifico's Blog

云深不知归处

LeetCode Solution(Easy.85-88)

c/c++,python,for work

85.Number of Boomerangs Given n points in the plane that are all pairwise distinct, a “boomerang” is a tuple of points (i, j, k) such that the distance between i and j equals the distance between ...

LeetCode Solution(Easy.81-84)

c/c++,python,for work

81.First Unique Character in a String Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. Examples: s = "leetcode" return 0. s = ...

LeetCode Solution(Easy.77-80)

c/c++,python,for work

77.Ransom Note Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from...

LeetCode Solution(Easy.73-76)

c/c++,python,for work

73.Island Perimeter You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally)....

LeetCode Solution(Easy.69-72)

c/c++,python,for work

69.Hamming Distance The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance....

LeetCode Solution(Medium.17-20)

c/c++,python,for work

17.Unique Paths A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is tr...

LeetCode Solution(Medium.13-16)

c/c++,python,for work

13.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 13.Integer to Roman-Analysis 这个是要求把整数转换成罗马数字。和之前的easy系列中的14题是相反的 ...

LeetCode Solution(Medium.9-12)

c/c++,python,for work

9.Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume ...

LeetCode Solution(Medium.5-8)

c/c++,python,for work

5.Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]....

LeetCode Solution(Medium.1-4)

c/c++,python,for work

前言 从本篇开始,做所有Medium难度的题目 1.Single Number Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexit...