space

Finding the index of a given permutation

此生再无相见时 提交于 2019-11-27 06:10:59
问题 I'm reading the numbers 0, 1, ..., (N - 1) one by one in some order. My goal is to find the lexicography index of this given permutation, using only O(1) space. This question was asked before, but all the algorithms I could find used O(N) space. I'm starting to think that it's not possible. But it would really help me a lot with reducing the number of allocations. 回答1: Considering the following data: chars = [a, b, c, d] perm = [c, d, a, b] ids = get_indexes(perm, chars) = [2, 3, 0, 1] A

Reading text file with multiple space as delimiter in R

左心房为你撑大大i 提交于 2019-11-27 05:31:04
问题 I have big data set which consist of around 94 columns and 3 Million rows. This file have single as well as multiple spaces as delimiter between columns. I need to read some columns from this file in R. For this I tried using read.table() with options which can be seen in the code below, the code is pasted below- ### Defining the columns to be read from the file, the first 5 column, then we do not read next 24, after this we read next 5 columns. Last 60 columns are not read in- col_classes =

Removing body margin in CSS

余生长醉 提交于 2019-11-27 04:47:31
I'm new to web development, and met a problem when removing margin of body. There's space between the very top of the browser and "logo" text. And my code is here on jsbin . Is body { margin: 0;} wrong if I'd like to remove the space? I would say that using: * { margin: 0; padding: 0; } is a bad way of solving this. The reason for the h1 margin popping out of the parent is that the parent does not have a padding. If you add a padding to the parent element of the h1, the margin will be inside the parent. Resetting all paddings and margins to 0 can cause a lot of side effects. Then it's better

jQuery serialize converts all spaces to plus

爱⌒轻易说出口 提交于 2019-11-27 03:45:23
问题 Currently, everywhere I use serialize I have to use it like this: .serialize().replace(/\+/g,'%20'); otherwise any spaces in the form data will be coverted to +'s. Is there a setting that can make this the default. 回答1: For fun, here's an alternative that doesn't use a temporary variable: $.fn.serializeAndEncode = function() { return $.map(this.serializeArray(), function(val) { return [val.name, encodeURIComponent(val.value)].join('='); }).join('&'); }; $("#formToSerialize")

EXCEL VBA Check if entry is empty or not 'space'

亡梦爱人 提交于 2019-11-27 02:37:47
问题 Note. Check if the TextBox1 is empty is easy by using TextBox1.Value = "" . But the problem is when the user hit the spacebar , TextBox1 will still recognize it as a value. In such case, my data will appear as an empty cell with 1 space inside. So my question is, is there any method to check TextBox1.value for empty and also not consist of space whether there are 1 or more space ? Million thanks to all. 回答1: A common trick is to check like this: trim(TextBox1.Value & vbnullstring) =

Replacing tab characters in JavaScript

£可爱£侵袭症+ 提交于 2019-11-27 01:49:39
问题 Please consider the following HTML <pre> element: This is some example code which      contains tabs I would like to replace all of the tab characters with four non-breaking space characters in HTML (i.e.  ). I have tested the above pre element with JavaScript for the presence of tab characters as follows: $('pre').ready(function() { alert(/\t/.test($(this).text())); }); But it is always returned false. Can anyone tell me the correct process by which to replace tab spaces from the source code

Right aligned UITextField spacebar does not advance cursor in iOS 7

倖福魔咒の 提交于 2019-11-27 00:20:56
问题 In my iPad app, I noticed different behavior between iOS 6 and iOS 7 with UITextFields. I create the UITextField as follows: UIButton *theButton = (UIButton*)sender; UITextField *textField = [[UITextField alloc] initWithFrame:[theButton frame]]; [textField setDelegate:self]; [textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; [textField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight]; textField.textAlignment = UITextAlignmentRight;

Fiill the space between two text elements with dots [duplicate]

和自甴很熟 提交于 2019-11-26 23:30:48
问题 This question already has answers here : Fill available spaces between labels with dots or hyphens (6 answers) Closed 2 years ago . I'm trying to figure out how to automatically fill space between two objects. I have menu items and prices. The goal is something like this: Burger..........................$9.99 Steak and Potato.........$14.99 Mac and Cheese.........$6.99 The spacing between menu item and price should be the same. Users can enter the menu item and price and I need to fill in any

In bash, how do I expand a wildcard while it's inside double quotes?

跟風遠走 提交于 2019-11-26 23:06:45
I would like to write the following function in bash: go() { cd "~/project/entry ${1}*" } What this would do is to cd into a project subdirectory with prefix entry (note space) and possibly a long suffix. I would only need to give it a partial name and it will complete the suffix of the directory name. So, if for example, I have the following folders: ~/project/entry alpha some longer folder name ~/project/entry beta another folder name ~/project/entry gamma I can run go b and it will put me into ~/project/entry beta another folder name . The problem is, of course, that the wildcard doesn't

How to create string with multiple spaces in JavaScript

元气小坏坏 提交于 2019-11-26 22:50:52
问题 By creating a variable var a = 'something' + ' ' + 'something' I get this value: 'something something' . How can I create a string with multiple spaces on it in JavaScript? 回答1: Use \xa0 - it is a NO-BREAK SPACE char. Reference from UTF-8 encoding table and Unicode characters, you can write as below: var a = 'something' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + 'something'; 回答2: Use   It is the entity used to represent a non-breaking space. It is essentially a standard space, the primary difference