算法设计
Ji_Liguo
这个作者很懒,什么都没留下…
展开
-
n-queens-ii
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.可参考上一篇博客,这里只需要产生一个 可行解,就将计数器count++import java.util.*;public原创 2017-07-17 18:41:31 · 251 阅读 · 0 评论 -
n-queens
The n-queens puzzle is the problem of placing n queens on an n×nchessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.原创 2017-07-17 18:31:43 · 295 阅读 · 0 评论 -
leetCode--linked-list-cycle-ii
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?分析:串长a + n,其中n为循环,当a + b步的慢指针与快指针相遇原创 2017-07-01 18:08:06 · 167 阅读 · 0 评论 -
leetCode--reorder-list
Given a singly linked list L: L 0→L 1→…→L n-1→L n,reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reor原创 2017-07-01 17:50:39 · 319 阅读 · 0 评论 -
leetcode--max-points-on-a-line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line分析:2点确定一条直线,在这个过程中,需要注意和第一个重复的点,这个点只能看成一个public class Solution { public int maxPoints(Point[]原创 2017-06-30 15:54:38 · 240 阅读 · 0 评论 -
leetcode--evaluate-reverse-polish-notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3"原创 2017-06-30 15:23:35 · 301 阅读 · 0 评论 -
leetCode--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.分析:很简单,先原创 2017-06-30 14:33:46 · 247 阅读 · 0 评论 -
leetcode--symmetric-tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the原创 2017-06-30 14:27:22 · 257 阅读 · 0 评论 -
java复习——this instanceof super关键字的用法
在Java语言中,当创建一个对象后,Java虚拟机就会为其分配一个指向对象本身的指针,这个指针就是“this”。使用this调用本类中的成员变量(属性)使用this调用构造方法使用this引用当前对象super 关键字与 this 类似,this 用来表示当前类的实例,super 用来表示父类。super 可以用在子类中,通过点号(.)来获取父类的成原创 2017-05-24 19:01:25 · 959 阅读 · 0 评论 -
java复习—— static static final 关键字的使用方式
1. 静态方法 通常,在一个类中定义一个方法为static,那就是说,无需本类的对象即可调用此方法声明为static的方法有以下几条限制:它们仅能调用其他的static 方法。 它们只能访问static数据。 它们不能以任何方式引用this 或super2. 静态变量声明为static的变量实质上就是全局变量。3.静态类原创 2017-05-24 18:57:20 · 369 阅读 · 0 评论 -
next-permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible原创 2017-07-17 19:14:12 · 346 阅读 · 0 评论