题目:两整数相除 难度:Medium 题目内容: Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward zero. 翻…
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward zero. Example 1:             Inp…
题目难度:Medium 题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate quadrup…
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. 翻译: 给定一组整数,两个数字的返回索引,它们的和会等于一个特定…
题目:求所有全排列 难度:Medium 题目内容: Given a collection of distinct integers, return all possible permutations. 翻译:给定一组各不相同的整数,返回所有可能的排列. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 我的思路:每种情况中,每一个元素只出现一次,只是之间的顺序不同,那么…
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. 翻译: 给定一组整数,两个数字的返回索引,它们的和会等于一个特定…
Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 解题思路: 模拟除法运算,但是不能试用 * / % 操作. 先思考边界条件,再开始做题: 0.除数为0无意义,需要和出题人沟通此边界是否存在(leetcode中并未考察除数为0的情况,默认除数不为0): 1.传入被除数/除数两个int做除法,什么情况返回值overflow:被…
题目 Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT 链接 https://leetcode.com/problems/divide-two-integers/ 答案 1.int的最大值MAX_INT为power(2,31)-1 = 2147483647 2.int的最小值MIN_INT为-power(2,31) = -21…
题目难度:hard There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: n…
题目难度:hard There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: n…