上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 49 下一页

2014年11月24日

Insertion Sort List

摘要: Insertion Sort ListSort a linked list using insertion sort.这道题用两个链表做的,这样方便一点。还有新链表头结点我没有存放内容,这样也比较方便,后面返回head1.next就好了 1 /** 2 * Definition for singl... 阅读全文

posted @ 2014-11-24 23:02 luckygxf 阅读(172) 评论(0) 推荐(0)

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

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

posted @ 2014-11-24 20:56 luckygxf 阅读(280) 评论(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 阅读(160) 评论(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 阅读(174) 评论(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 阅读(135) 评论(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 阅读(146) 评论(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 阅读(145) 评论(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 阅读(498) 评论(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 阅读(227) 评论(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 阅读(135) 评论(0) 推荐(0)

上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 49 下一页

导航