prefix

Determine if one string is a prefix of another

旧时模样 提交于 2020-01-13 12:00:12
问题 I have written down a simple function that determines if str1 is a prefix of str2. It's a very simple function, that looks like this (in JS): function isPrefix(str1, str2) // determine if str1 is a prefix of a candidate string { if(str2.length < str1.length) // candidate string can't be smaller than prefix string return false; var i = 0; while(str1.charAt(i) == str2.charAt(i) && i <= str1.length) i++; if(i < str1.length) // i terminated => str 1 is smaller than str 2 return false; return true

CondaValueError: Value error: prefix already exists:

▼魔方 西西 提交于 2020-01-13 03:13:06
问题 Reference: https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/ I've run the following commands to install conda and create a virtual environment. Continue reading after code block for my question. C:\Windows\System32>conda -V conda 4.1.11 C:\Windows\System32>conda update conda Fetching package metadata ......... Solving package specifications: .......... Package plan for installation in environment C:\Program Files\Miniconda2: The following packages will be downloaded:

LC14. 最长公共前缀

一曲冷凌霜 提交于 2020-01-12 19:24:05
1. 神仙算法 /** * @Classname Solution1 * @Description TODO * @Date 2020/1/11 7:00 * @Author SonnSei */ public class Solution1 { /** * 神仙算法 * 时间复杂度:O(s),s为所有字符总数 * 空间复杂度:O(1) * @param strs * @return */ public String longestCommonPrefix ( String [ ] strs ) { if ( strs == null || strs . length == 0 ) return "" ; String prefix = strs [ 0 ] ; for ( int i = 1 ; i < strs . length ; i ++ ) { while ( strs [ i ] . indexOf ( prefix ) != 0 ) { prefix = prefix . substring ( 0 , prefix . length ( ) - 1 ) ; if ( prefix . isEmpty ( ) ) return "" ; } } return prefix ; } } 2. 愚蠢的BF /** * @Classname Solution2 *

JS—全屏或退出全屏

柔情痞子 提交于 2020-01-11 15:34:29
根据屏幕浏览器高度进行判断,进入全屏或退出全屏 <style> .icon-fullscreen { margin-left : 72.5% ; } .icon-exitFullscreen { margin-left : 71% ; } </style> $ ( '#fullscreen' ) . css ( 'margin-left' , '71%' ) ; $ ( function ( ) { changeClass ( ) ; } ) ; //浏览器的窗口大小发生改变时执行 $ ( window ) . resize ( function ( ) { //执行代码块 changeClass ( ) ; } ) ; //当屏幕小于891时添加一个属性,大于的时候删除属性 function changeClass ( ) { var hh = $ ( window ) . height ( ) ; if ( hh > 891 ) { $ ( '#fullscreen' ) . css ( 'margin-left' , '' ) ; $ ( '#fullscreen' ) . removeClass ( 'icon-exitFullscreen' ) . addClass ( 'icon-fullscreen' ) ; } else { $ ( '#fullscreen' )

Configuring install path: prefix=[PREFIX] not fully understood

会有一股神秘感。 提交于 2020-01-11 09:23:25
问题 I think this is simply a general c++ question: I'm attempting to compile a local version of ffmpeg on Linux Fedora using the gnu c++ compiler. I have source code in a bunch of folders under: ~/<username>/Downloads/Code/ffmpeg_sources/ which is where I'm attempting to set the config flags to install the build to a target not under this tree but at a root level directory with local shared libraries: /usr/local/ There is this following section near the beginning of the configuration file:

字典树(Trie树)实现与应用

余生长醉 提交于 2020-01-10 18:21:47
一、概述   1、基本概念   字典树,又称为单词查找树,Tire数,是一种树形结构,它是一种哈希树的变种。      2、基本性质 根节点不包含字符,除根节点外的每一个子节点都包含一个字符 从根节点到某一节点。路径上经过的字符连接起来,就是该节点对应的字符串 每个节点的所有子节点包含的字符都不相同   3、应用场景   典型应用是用于统计,排序和保存大量的字符串(不仅限于字符串),经常被搜索引擎系统用于文本词频统计。   4、优点   利用字符串的公共前缀来减少查询时间,最大限度的减少无谓的字符串比较,查询效率比哈希树高。 二、构建过程   1、字典树节点定义 class TrieNode // 字典树节点 { private int num;// 有多少单词通过这个节点,即由根至该节点组成的字符串模式出现的次数 private TrieNode[] son;// 所有的儿子节点 private boolean isEnd;// 是不是最后一个节点 private char val;// 节点的值 TrieNode() { num = 1; son = new TrieNode[SIZE]; isEnd = false; } }   2、字典树构造函数 Trie() // 初始化字典树 { root = new TrieNode(); }   3、建立字典树 // 建立字典树

Spring攻略学习笔记(2)------配置Spring IoC容器中的Bean

强颜欢笑 提交于 2020-01-09 06:33:41
(1) 每个Bean都应该提供一个 唯一的名称或id ,以及一个完全限定的类名,用来让IoC容器对其进行实例化 。对于简单类型的每个bean属性(例如String和其他简单类型),可以为其指定一个<value>元素。Spring会试图将你指定的值转换为该属性的声明类型。为了通过setter注入配置一个属性,可使用<property>元素,并在其name属性中指定属性名称。注意: 每个<property>要求bean包含对应的一个setter方法 。如下: <bean name="sequenceGenerator" class="com.jackie.codeproject.springrecipesnote.springioc.SequenceGenerator"> <property name="prefix"> <value>30</value> </property> <property name="suffix"> <value>A</value> </property> <property name="initial"> <value>100000</value> </property> </bean> 也可以在<constructor-arg>元素中声明,通过构造函数注入配置Bean属性。 书上说<constructor-arg

How can I prefix ordered list item numbers with a static string using CSS?

╄→гoц情女王★ 提交于 2020-01-09 05:22:36
问题 I want this HTML... <ol style="list-style:decimal;"> <li>Apples</li> <li>Oranges</li> </ol> ...to render like this Q1. Apples Q2. Oranges In other words, I want the auto-generated numbers to be prefixed with the static string "Q". I've tried CSS like this: ol li:before { content:"Q"; } But that produces this: QApples QOranges I've also tried using "list-style:numbered inside;", but that just shifts the list to the right with the same results. I can't find a way to reference the auto-generated

Linux如何安装卸载软件

会有一股神秘感。 提交于 2020-01-08 23:36:51
/*--> */ /*--> */ Linux 中如何卸载已安装的软件 .     Linux 软件的安装和卸载一直是困扰许多新用户的难题。在 Windows 中,我们可以使用软件自带的安装卸载程序或在控制面板中的“添加 / 删除程 序” 来实现。与其相类似,在 Linux 下有一个功能强大的软件安装卸载工具,名为 RPM 。它可以用来建立、安装、查询、更新、卸载软件。该工具是在命令 行下使用的。在 Shell 的提示符后输入 rpm ,就可获得该命令的帮助信息。   软件的安装    Linux 下软件的安装主要有两种不同的形式。第一种安装文件名为 xxx.tar.gz ;另一种安装文件名为 xxx.i386.rpm 。以第一种方式发行的软件多为以源码形式发送的;第二种方式则是直接以二进制形式发送的。   对于第一种,安装方法如下:    1 . 首先,将安装文件拷贝至你的目录中。例如,如果你是以 root 身份登录上的,就将软件拷贝至 /root 中。    #cp xxx.tar.gz /root    2 . 由于该文件是被压缩并打包的 , 应对其解压缩。命令为:    #tar xvzf filename.tar.gz 如果是 filename.tar.bz2 格式的,应该是 tar jxvf filename.tar.bz2 来解压    3. 执行该命令后

Linux configure 参数解释

て烟熏妆下的殇ゞ 提交于 2020-01-08 05:04:24
  Linux环境下的软件安装,并不是一件容易的事情;如果通过源代码编译后在安装,当然事情就更为复杂一些;现在安装各种软件的教程都非常普遍;但万变不 离其中,对基础知识的扎实掌握,安装各种软件的问题就迎刃而解了。Configure脚本配置工具就是基础之一,它是autoconf的工具的基本应用。   与一些技巧相比,Configure显得基础一些,当然使用和学习起来就显得枯燥乏味一些,当然要成为高手,对基础的熟悉不能超越哦。  为此我转载了一篇关于Configure选项配置的详细介绍。供大家参考 'configure'脚本有大量的命令行选项.对不同的软件包来说,这些选项可能会有变化,但是许多基本的选项是不会改变的.带上'--help'选 项执行'configure'脚本可以看到可用的所有选项.尽管许多选项是很少用到的,但是当你为了特殊的需求而configure一个包时,知道他们的 存在是很有益处的.下面对每一个选项进行简略的介绍: --cache-file=FILE   'configure'会在你的系 统上测试存在的特性(或者bug!).为了加速随后进行的配置,测试的结果会存储在一个cache file里.当configure一个每个子树里都有'configure'脚本的复杂的源码树时,一个很好的cache file的存在会有很大帮助. --help   输出帮助信息