This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| maxSum' :: [Int] -> Int -> Int -> Int | |
| maxSum' [] maxEnd maxSofar = maxSofar | |
| maxSum' (x:xs) maxEnd maxSofar = | |
| maxSum' xs maxEnd' (max maxSofar maxEnd') | |
| where maxEnd' = max (maxEnd + x) 0 | |
| maxSum :: [Int] -> Int | |
| maxSum arr = maxSum' arr 0 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module IP where | |
| import System.IO | |
| import qualified Data.ByteString.Lazy as BL | |
| import qualified Data.ByteString.Lazy.UTF8 as UTF8 | |
| import Data.Binary.Get | |
| import Data.Word | |
| import Data.Char | |
| import Numeric | |
| import Data.Bits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package algrithsm | |
| import annotation.tailrec | |
| /** | |
| * User: flower | |
| * Date: 11-1-18 | |
| * Time: 下午6:22 | |
| * Description: | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 动态规划 | |
| * | |
| * 生产计划问题 解答 | |
| * | |
| * 工厂生产某种产品,每单位(千件)的成本为1(千元), | |
| * 每次开工的固定成本为3(千元),工厂每季度的最大生产能力为6(千件)。 | |
| * 经调查,市场对该产品的需求量第一、二、三、四季度分别为 2,3,2,4(千件)。 | |
| * 如果工厂在第一、二季度将全年的需求都生产出来, | |
| * 自然可以降低成本(少付固定成本费), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package algrithsm | |
| import collection.mutable.Stack | |
| import org.slf4j.{LoggerFactory, Logger} | |
| import Console._ | |
| /** | |
| * User: flower | |
| * Date: 11-3-29 | |
| * Time: 下午3:04 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package data | |
| import java.util.Date | |
| object HeapSort { | |
| class MaxHeap[T <% Ordered[T] : ClassManifest](val initialSize: Int) { | |
| private var underlying: Array[T] = new Array[T](initialSize + 1); | |
| private var size = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package data | |
| /** | |
| * MergeSort | |
| * User: flower | |
| * Date: 2010-10-18 | |
| * Time: 19:27:14 | |
| */ | |
| import java.util.Date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package t1 | |
| object Just { | |
| def main(arg : Array[String]) : Unit = { | |
| val a = new Array[Int](10) | |
| val x = Array(6, 23, 123, 5563, 345, 11); | |
| quicksort(x) foreach println |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package t1 | |
| object BinarySearchTree { | |
| def mkTree[K <% Ordered[K], T](key : K, v : T) : Tree[K, T] = | |
| new Node(key, v, Empty, Empty) | |
| case class Person(id : String, name : String) | |
| def main(args : Array[String]) : Unit = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package t1; | |
| public class JavaBinaryTree{ | |
| static class Empty extends BinaryTreeMap{ | |
| protected Empty(){} | |
| @Override | |
| public boolean isEmpty(){ | |
| return true; |
OlderNewer