This file contains 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 com | |
import scala.collection.mutable | |
import scala.io.Source | |
object NonDivisibleSubset { | |
def main(args: Array[String]): Unit = { | |
val target = Source.fromFile("").mkString.split(" ").map(_.toInt) | |
println(target.length) |
This file contains 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
def appendAndDelete(s: String, t: String, k: Int): String = { | |
val sLength = s.length | |
val tLength = t.length | |
val minLength = Math.min(sLength, tLength) | |
var done = false | |
var index = 0 | |
while (done == false && index < minLength) { | |
if (s(index).equals(t(index)) == false) { | |
done = true | |
} else { |
This file contains 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 com | |
import scala.collection.mutable.ArrayBuffer | |
object MagicSquare { | |
def main(args: Array[String]): Unit = { | |
val target = Array[Array[Int]]( | |
Array[Int](4, 8, 2), |
This file contains 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 com | |
import scala.collection.mutable.ArrayBuffer | |
object PermutationQuestion { | |
def main(args: Array[String]): Unit = { | |
val candidates = ArrayBuffer[Int](1, 3, 7, 5, 9) | |
val count = 3 | |
val container = getAllPermutations(count, candidates) |
This file contains 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 com; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.logging.Logger; | |
import java.util.regex.Pattern; | |
public class PatternQuestion { |
This file contains 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 com | |
import scala.collection.mutable.ArrayBuffer | |
object CombinationQuestion { | |
def main(args: Array[String]): Unit = { | |
val candidates = ArrayBuffer[Int](1, 3, 7, 5, 9) | |
val count = 3 | |
val container = getAllCombinations(count, candidates) |
This file contains 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
<?php | |
/** | |
* Created by PhpStorm. | |
* User: dailybird | |
* Date: 17/6/1 | |
* Time: 下午11:57 | |
*/ | |
$nodes = [ |
This file contains 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
<?php | |
date_default_timezone_set('PRC'); | |
$filename = 'messages.txt'; | |
$username = $_POST['username'] ?? null; | |
$title = $_POST['title'] ?? null; | |
$content = $_POST['content'] ?? null; | |
if(!is_null($username) && !is_null($title) && !is_null($content)){ |
This file contains 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
int upperBit(x) | |
{ | |
int count = 0; | |
while(x) | |
{ | |
count++; | |
x = x & (x-1); | |
} | |
return count; | |
} |
This file contains 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
<?php | |
/** | |
* 打印金字塔 | |
* @param [int] $level [层数] | |
* @return [void] | |
*/ | |
function pyramidPrinter($level){ | |
for ($index = 1; $index <= $level; $index++) { | |
for ($space = $level; $space > $index; $space--) { |
NewerOlder