
leetcode
学习编程知识
爱好编程,上手快,学习能力强,阅读文档,对log、error信息良好的嗅觉
展开
-
leetcode Count Primes 统计 素数 个数 超时 解决方案
Count Primes Description:Count the number of prime numbers less than a non-negative number, n.public class CountPrimes { public static void main(String[] args) { System.out.println(countPri原创 2015-08-09 12:40:10 · 1745 阅读 · 0 评论 -
LeetCode OJ Valid Anagram 字符串
Valid Anagram Total Accepted: 8432 Total Submissions: 23731 My Submissions Question Solution Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagra原创 2015-08-06 22:50:38 · 806 阅读 · 0 评论 -
Single Number II LeetCode
Single Number II Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you im原创 2015-08-18 23:30:25 · 475 阅读 · 0 评论 -
Wildcard Matching
Implement wildcard pattern matching with support for ‘?’ and ‘*’.https://leetcode.com/problems/wildcard-matching/'?' Matches any single character.'*' Matches any sequence of characters (including the原创 2015-08-06 13:04:10 · 601 阅读 · 0 评论 -
Leetcode Best Time to Buy and Sell Stock II OJ 刷题 算法
Best Time to Buy and Sell Stock II ay you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many原创 2015-08-15 15:48:40 · 734 阅读 · 0 评论 -
LeetCode Number of 1 Bits 刷题 OJ
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).Wrong Solutionpublic class NumberOfBits { public st原创 2015-08-15 14:38:28 · 574 阅读 · 0 评论 -
LeetCode Invert Binary Tree OJ 刷题 算法
Invert Binary Tree Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \Solutionimport java.util.ArrayList;import java.util.List;public class原创 2015-08-16 10:44:26 · 630 阅读 · 0 评论 -
从左往右 从上往下 按层遍历 输出 树 二叉树
需求 将二叉树的 各节点输出, 按照层级输出 4 / \ 2 7 / \ / \1 3 6 9方法1public static void outputTree(TreeNode root) { if (root == null) { return; } System.out.println(root);原创 2015-08-16 11:12:16 · 2291 阅读 · 1 评论 -
LeetCode Lowest Common Ancestor of a Binary Search Tree 刷题 OJ 算法
Lowest Common Ancestor of a Binary Search Tree Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipe原创 2015-08-15 16:45:36 · 652 阅读 · 0 评论 -
LeetCode Same Tree OJ 算法 刷题
Same Tree Given 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.原创 2015-08-15 11:25:28 · 610 阅读 · 0 评论 -
Majority Element LeetCode OJ 刷题
Majority Element Majority Element 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原创 2015-08-15 09:33:19 · 540 阅读 · 0 评论 -
LeetCode Delete Node in a Linked List 刷题 OJ 算法
Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are原创 2015-08-15 10:54:16 · 665 阅读 · 0 评论 -
LeetCode 找出 单独的数 Single Number
Single Number Description Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could原创 2015-08-11 11:16:25 · 847 阅读 · 0 评论 -
leetcode Maximum Depth of Binary Tree 树的深度
Maximum Depth of Binary Tree Description 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 l原创 2015-08-11 18:29:07 · 530 阅读 · 0 评论 -
LeetCode Pascal's Triangle 杨辉三角 Java
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] ]这道题比较简单, 杨辉原创 2015-08-06 23:07:34 · 1329 阅读 · 1 评论 -
java 传值 还是 传引用
前言大家都知道,对于基本类型(int char float等等),java是传值。对于某个对象,java传递的是什么呢?疑惑 最近刷 leetcode 删除链表一个节点的时候, 遇到这个问题 看下面代码public class DeleteNodeLinkedList { public static void main(String[] args) { List原创 2015-08-15 10:50:10 · 1375 阅读 · 0 评论