【LeetCode从零单排】No221.Maximal Square

题目Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Retur...
阅读(948) 评论(0)

【LeetCode从零单排】No133. clon graph (BFS广度优先搜索)

背景(以下背景资料转载自:http://www.cnblogs.com/springfor/p/3874591.html?utm_source=tuicool)DFS(Dpeth-first Search)顾名思义,就是深度搜索,一条路走到黑,再选新的路。记得上Algorithm的时候,教授举得例子就是说,DFS很像好奇的小孩,你给这个小孩几个盒子套盒子,好奇的小孩肯定会一个盒子打开后继续再在这个...
阅读(1182) 评论(0)

【LeetCode从零单排】No121 Best Time to Buy and Sell Stock

题目Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), d...
阅读(931) 评论(0)

单链表问题(反转、是否有环、删除结尾第N个节点、合并两个sortlist、找到交点)

1.时间复杂度O(N),内存O(1)的效率下实现单链表的翻转public static TreeNode revers(TreeNode head){ TreeNode temp,first,second; first=head; second=head.next; while(second!=null){ temp=second.next; second.next=...
阅读(1126) 评论(0)

【LeetCode从零单排】No96 Unique Binary Search Trees

题目Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ ...
阅读(1009) 评论(0)

【LeetCode从零单排】No129 Sum Root to Leaf Numbers

题目Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of...
阅读(849) 评论(0)

【LeetCode从零单排】No15 3Sum

题目Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c) must be ...
阅读(764) 评论(0)

【LeetCode从零单排】No 3 Longest Substring Without Repeating Characters

题目Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
阅读(925) 评论(0)

【LeetCode从零单排】No 114 Flatten Binary Tree to Linked List

题目Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 ...
阅读(912) 评论(0)

【LeetCode从零单排】No 191.Number of 1 Bits(考察位运算)

题目Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 0000000000...
阅读(3906) 评论(2)

【LeetCode从零单排】No189 .Rotate Array

题目Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as you can, the...
阅读(1026) 评论(0)

【LeetCode从零单排】No.169 Majority Element(hashmap用法)

题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alwa...
阅读(971) 评论(0)

【LeetCode从零单排】No.160 Intersection of Two Linked Lists

题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ ...
阅读(783) 评论(0)

【LeetCode从零单排】No118 Pascal's Triangle

题目Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]代码public class Solution { public...
阅读(1027) 评论(0)

【LeetCode从零单排】No112 Path Sum

题目Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum = ...
阅读(980) 评论(0)

【LeetCode从零单排】No104 Maximum Depth of Binary Tree

题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.代码/** * Definition for binary tree * p...
阅读(988) 评论(0)

【LeetCode从零单排】No102 Binary Tree Level Order Traversal

题目       Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 /...
阅读(1055) 评论(2)

【LeetCode从零单排】No100 Same Tree && No101 Symmetric Tree

题目1.same treeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.2.sym...
阅读(966) 评论(0)

【LeetCode从零单排】No83 Remove Duplicates from Sorted List

题目Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.代码 public static ListNode deleteD...
阅读(908) 评论(0)

【LeetCode从零单排】No88.Merge Sorted Array

题目Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. T...
阅读(886) 评论(0)
49条 共3页1 2 3 下一页 尾页
    我的微信公众号

    作者公众号:凡人机器学习

    凡人机器学习

    作者新书《机器学习实践应用》
    个人资料
    • 访问:638820次
    • 积分:9068
    • 等级:
    • 排名:千里之外
    • 原创:215篇
    • 转载:33篇
    • 译文:0篇
    • 评论:417条
    博客专栏
    统计