剑指offer-二进制中1的个数-java

题目描述: 输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。 思路解析:https://www.nowcoder.com/questionTerminal/8ee967e43c2c4ec193b040ea7fbb10b8 如果一个整数不为0,那么这个整数至少有一位是1。如果我...

2018-09-06 10:05:10

阅读数 47

评论数 0

剑指offer-用栈实现队列-java

题目描述: 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 思路解析: 入栈:栈1是用来入栈的,栈2是辅助;           如果栈2是空的,直接入栈到栈1中,如果栈2不为空,那么就先把栈2中的push回栈1中,再入栈。 出栈:栈2是用来出栈的,...

2018-09-05 14:34:08

阅读数 37

评论数 0

LeetCode—subsets(子集dfs)—java

题目描述:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must...

2018-07-15 00:13:04

阅读数 344

评论数 0

LeetCode—sort-colors(颜色012排序)—java

题目描述:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order...

2018-07-14 00:18:26

阅读数 202

评论数 0

LeetCode—search-a-2d-matrix(排好序的矩阵中查找)—java

题目描述:Write an efficient algorithm that searches for a value in anm x n matrix. This matrix has the following properties:Integers in each row are sort...

2018-07-13 23:48:44

阅读数 108

评论数 0

LeetCode—set-matrix-zeroes(矩阵置0)—java

题目描述:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra...

2018-07-13 23:03:54

阅读数 97

评论数 0

LeetCode—simplify-path(简化路径)—java

题目描述:Given an absolute path for a file (Unix-style), simplify it.For example,path ="/home/", =>"/home"...

2018-07-13 18:42:51

阅读数 297

评论数 0

LeetCode—merge-two-sorted-lists(合并链表)—java

题目描述:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路解...

2018-07-12 19:42:13

阅读数 56

评论数 0

LeetCode—unique-paths_iiunique-paths_minimum-path-sum_climbing-stairs_edit-distance(动态规划)——java

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

2018-07-12 19:06:01

阅读数 50

评论数 0

LeetCode—permutation-sequence(全排列的第k个)—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 seque...

2018-07-08 00:05:32

阅读数 287

评论数 0

LeetCode—spiral-matrix-ii(螺旋赋值)—java

题目描述:Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order.For example,Given n =3,You should return the fol...

2018-07-06 00:14:22

阅读数 61

评论数 0

LeetCode—length-of-last-word(最后一个单词的长度)—java

题目描述:Given a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last ...

2018-07-05 23:52:52

阅读数 337

评论数 0

LeetCode—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 i...

2018-07-05 23:39:40

阅读数 148

评论数 0

LeetCode—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].思路解析:题意:...

2018-07-05 01:17:17

阅读数 386

评论数 0

LeetCode—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:[...

2018-07-05 00:28:11

阅读数 284

评论数 0

LeetCode—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,−...

2018-06-28 22:01:54

阅读数 167

评论数 0

LeetCode—n-queens-ii(返回解决方案的总数)—java

题目描述:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路解析:跟第一个题一样的解决方法,但是需...

2018-06-28 19:19:04

阅读数 59

评论数 0

LeetCode—n-queens(n皇后问题)—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...

2018-06-28 18:05:28

阅读数 414

评论数 0

LeetCode—powx-n(x的n次)—java

题目描述:Implement pow(x, n).思路解析:pow(x,n)分解为pow(x,n/2)*pow(x,n/2) ,但是需要区分奇数偶数。还要看n的正负号。代码:public class Solution { public double pow(double x, int n)...

2018-06-24 14:22:25

阅读数 59

评论数 0

LeetCode—anagrams(返回由相同字母组成的单词)—java

题目描述:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路解析:首先判空然后需要创建HashMap来存储排序好的字符...

2018-06-24 14:00:51

阅读数 240

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭