上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 46 下一页

2014年11月24日

回溯(su)算法之N皇后问题

摘要: 这里回溯算法还要好好研究一下试探一个位置是否有效,如果有效,试探下一个位置(DFS),如果无效则回退1.定义一个解空间,存放一个解的空间2.DFS(暂且认为是DFS)这里N皇后用的是递归+回溯实现的 1 package com.gxf.backtracking; 2 3 /** 4 * n皇后问... 阅读全文

posted @ 2014-11-24 20:56 luckygxf 阅读(264) 评论(0) 推荐(0) 编辑

N-Queens

摘要: N-QueensThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all... 阅读全文

posted @ 2014-11-24 20:49 luckygxf 阅读(151) 评论(0) 推荐(0) 编辑

2014年11月22日

Search Insert Position

摘要: Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if ... 阅读全文

posted @ 2014-11-22 12:04 luckygxf 阅读(164) 评论(0) 推荐(0) 编辑

2014年11月21日

Swap Nodes in Pairs

摘要: Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2-... 阅读全文

posted @ 2014-11-21 16:29 luckygxf 阅读(127) 评论(0) 推荐(0) 编辑

2014年11月20日

Linked List Cycle

摘要: Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?这道题要用双指针,但我想试一下投机取巧的办法行不行... 阅读全文

posted @ 2014-11-20 19:56 luckygxf 阅读(130) 评论(0) 推荐(0) 编辑

Evaluate Reverse Polish Notation

摘要: Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may ... 阅读全文

posted @ 2014-11-20 19:05 luckygxf 阅读(133) 评论(0) 推荐(0) 编辑

java 词法分析器

摘要: 参考:http://www.cnblogs.com/yanlingyin/archive/2012/04/17/2451717.html实现了一个简单的java词法分析器功能:词法分析下面一段java小程序1 int sum = 0; for(int i = 1; i 9>=10= 'a' && i... 阅读全文

posted @ 2014-11-20 16:26 luckygxf 阅读(462) 评论(0) 推荐(0) 编辑

Triangle

摘要: TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given... 阅读全文

posted @ 2014-11-20 00:02 luckygxf 阅读(214) 评论(0) 推荐(0) 编辑

2014年11月19日

Maximum Product Subarray

摘要: Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given... 阅读全文

posted @ 2014-11-19 20:42 luckygxf 阅读(128) 评论(0) 推荐(0) 编辑

2014年11月18日

Minimum Path Sum

摘要: Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along ... 阅读全文

posted @ 2014-11-18 21:19 luckygxf 阅读(169) 评论(0) 推荐(0) 编辑

上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 46 下一页

导航