Elmagnifico's Blog

云深不知归处

LeetCode Solution(Easy.93-96)

c/c++,python,for work

93.Number Complement Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fi...

LeetCode Solution(Easy.89-92)

c/c++,python,for work

89.Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 89.Power of Three-Analysis 不用循环和递归判断是...

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 ...