leetcode 69 Sqrt(x) ---java
摘要:Implement int sqrt(int x). Compute and return the square root of x. 求一个数的平方根。 其实就是一个二分查找。 有两种查找方式 1、就是找到最大int值,然后从0到max,二分查找。 2、直接针对x,从0到x,二分查找。
阅读全文
leetcode 68 Text Justification ----- java
摘要:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You shou
阅读全文
leetcode 67 Add Binary ----- java
摘要:Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 两个二进制数相加,并不难。
阅读全文
leetcode 66 Plus One ----- java
摘要: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 a
阅读全文
leetcode 65 Valid Number ----- java
摘要:Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for the
阅读全文
leetcode 64 Minimum Path Sum ----- java
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
阅读全文
leetcode 63 Unique Paths II ---java
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space
阅读全文
leetcode 62 Unique Paths ---java
摘要: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 p
阅读全文
leetcode 61 Rotate List ----- java
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3-
阅读全文
leetcode 60 Permutation Sequence ----- java
摘要:The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence
阅读全文
leetcode 57 Insert Interval ----- java
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia
阅读全文
leetcode 56 Merge Intervals ----- java
摘要:Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 这道题就是合并所有集
阅读全文
leetcode 55 Jump Game ----- java
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Given an array of non-negative integers, you ar
阅读全文
leetcode 54 Spiral Matrix ----- java
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: You s
阅读全文
leetcode 53 Maximum Subarray ----- java
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,
阅读全文
leetcode 51 N-Queens & 52 N-Queens II ----- java
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all
阅读全文
leetcode 50 Pow(x, n) ---- java
摘要:Implement pow(x, n). 题目简单明了,就是求一个数的n次方。 注意两个问题即可:1、最小的int的绝对值要比最大的int大1,因此在转换的时候需要额外多乘一次x 2、在n比较大的情况下,直接将x乘n次会导致结果不准确,因为每一次结果只保留最后有限的数位,那么就要经可能的减少误差。
阅读全文
leetcode 49 Group Anagrams ---- java
摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i
阅读全文
leetcode 46 Permutations ----- java
摘要:Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: 给定一个数组,求所有的排列组合。 做出这道题很
阅读全文
leetcode 44 Wildcard Matching ----java
摘要:Implement wildcard pattern matching with support for '?' and '*'. 全匹配问题,也就是正则式的问题,题目要求两个字符串是否匹配,?代表任意一个字母,*代表任意个字母,也可以是0个。 第一次写的时候出现了很多问题,我用了递归,但由于*代表
阅读全文
|
|
|