Minimum words in a string given a dictionary

The question is: Given a dictionary consisting of a set of words and a string: find the minimum number of words the string can be split into. If the string can not be decomposed into a list of words return -1.

I tried finding the longest prefix and proceeding but that doesn’t seem to work. I searched this question online and found a similar stack exchange question but I believe that the solution provided is wrong. It looks like this person is finding the longest suffix and proceeding but this approach doesn’t work. Link to similar question

The reason this doesn’t work is because: Suppose the dictionary is:{i,iiiiface,facebook,book} and input instance is ‘iiiiifacebook’. The given solution would select ‘facebook’ and then continue to select 5 ‘i’s’ making a total of 6 words when infact the optimal solution is: (book,iiiiface,i) which is just 3 words. Please correct me if I’m wrong.

Please help me find the optimal (DP) solution to this problem.

Sharepoint: Pulling String information from a list item to populate external URL

I am working with Sharepoint 2013, and I have a list of items that have a client id. These client ids are references to a database referenced by another group. I am wanting to pull the string information from a list item to populate a variable in a URL for a Custom Action. Please see example for clarification.

enter image description here

I want to extract the actual ClientID to insert into a URL when clicked. (i.e.[ClientID_from_List_1]/showall.aspx

So if I clicked CASABONITAS ClientID in Sharepoint it would open a new page with the URL being

I have done some searching and cannot find any customized tokens that can be used for extracting this information, any assistance would be greatly appreciated.

What Is The Difference Between String, Stringbuilder, And Stringbuffer In Java?

What is the difference between String, StringBuilder, and StringBuffer in Java?

Website Designing Company in Bangalore | Website Designing Companies in Bangalore | Web Designing Companies in Bangalore | Website Design Companies in Bangalore | Web Design Company in Bangalore | Web…

What Is The Difference Between String, Stringbuilder, And Stringbuffer In Java?

Optimizar String

Tengo el siguiente codigo que crea elimina lo que hay entre medias de un String que comienze con /* y termine */ El problema es que creo que si se tratara de un String muy grande, supondría un problema de optimización de la memoria del programa.

introducir el código aquípublic class EntradaTeclado { public static void main(String[] args) {     String cadenaLimpia = ""     boolean addChar = true;     System.out.printf("Introduzca una frase que contenga los caracteres /* y */ \n");     String palabra = ""     Scanner scr = new Scanner(;     palabra = scr.nextLine();      for (int i = 0; i < palabra.length(); i++) {         if ((i + 2) < palabra.length() && palabra.substring(i, i + 2).equals("/*")) {             addChar = false;         } else if (i > 3 && palabra.substring(i - 2, i).equals("*/")) {             addChar = true;         } else if (addChar == true) {             cadenaLimpia = cadenaLimpia + palabra.substring(i, i + 1);         }     }     System.out.println("Cadena sin los caracteres /* y */: " + cadenaLimpia); } 

¿Alguna sugerencia?

Gracias, un saludo.

Probability of string misidentified in Bloom filter

I’m attempting a question related to Bloom filters:

Our Bloom filter uses $ 3$ different independent hash functions $ H_1, H_2, H_3$ that each take any string as input and each return an index into a bit-array of length $ n$ . Each index is equally likely for each hash function.

To add a string into the set, feed it to each of the $ 3$ hash functions to get $ 3$ array positions. Set the bits at all these positions to $ 1$ . For example, initially all values in the bit-array are zero. In this example $ n = 10$ :

Index: 0 1 2 3 4 5 6 7 8 9 Value: 0 0 0 0 0 0 0 0 0 0 

After adding the string “word”, where $ H_1($ “word”$ )=4$ , $ H_2($ “word”$ )=7$ and $ H_3($ “word”$ )=8$ :

Index: 0 1 2 3 4 5 6 7 8 9 Value: 0 0 0 0 1 0 0 1 1 0 

Bits are never switched back to $ 0$ . Consider a Bloom filter with $ n=9000$ buckets. You have added $ m=1000$ strings to the filter.

a) What is the probability that the first bucket has $ 0$ strings hashed to it?

b) To check whether a string is in the set, feed it to each of the $ 3$ hash functions to get $ 3$ array positions. If any of the bits at these positions is $ 0$ , the element is not in the set. If all bits at these positions are $ 1$ , the string may be in the set; but it could be that those bits are $ 1$ because some of the other strings hashed to the same values. You may assume that the value of one bucket is independent of the value of all others.

What is the probability that a string which has not previously been added to the set will be misidentified as in the set. That is, what is the probability that the bits at all of its hash positions are already $ 1$ ?

For the first part, probability that a certain string is not hashed by $ H_1$ to first bucket is $ 8999/9000$ . Probability that that string isn’t hashed by any of the $ 3$ functions is therefore $ (8999/9000)^3$ . Probability that none of the strings is hashed by any of the hashing functions to the first bucket is then $ (8999/9000)^{3000}$ .

I hope so far I’m going on the right track. I’m completely confused by the second part though. Am I supposed to use some specific probability distribution for this?

Edit: after Yuval’s comment, here’s an attempt at the second part: We’re supposed to find the probability that $ 3$ specific buckets (say buckets no. $ p,q,r$ ) already have a string hashed to them. This is

$ $ P(p=1,q=1,r=1)=1-P((p=0)\cup(q=0)\cup(r=0))$ $

The union can be calculated as (denoting events $ p=0, q=0, r=0$ as $ p_0, q_0, r_0$ respectively)

$ $ P(p_0\cup q_0\cup r_0)=\P(p_0)+P(q_0)+P(r_0)-P(p_0,q_0)-P(q_0,r_0)-P(r_0,p_0)+P(p_0,q_0,r_0)$ $

$ P(p_0),P(q_0),P(r_0)$ will be the same as the answer to the first question. $ P(p_0,q_0)$ will be (using similar logic as in part a) $ \big(\frac{8998}{9000}\big)^{3000}$ . $ P(p_0,q_0,r_0)$ will be $ \big(\frac{8997}{9000}\big)^{3000}$ . Plugging all these values in, we get the answer.

Is this okay?

There is a way to force to krunner to run any string in konsole?

I have kubuntu 19.04 installed and Im asking if there is a way to force to krunner to execute a string in konsole. Im trying to execute the string “jupyter lab” lo launch jupyter but the option to be run in konsole doesn’t appear.

Of course I can just open a console by CTRL+ALT+T and do it, by I want to know if there is a way to force a string to be executed as a console command from krunner. Thank you in advance.

Convertir un String a formato date Time en PHP

Una consulta,

Tengo una funcion la cual al entregarle una fecha especifica me retorna el primer dia de la semana de la fecha entregada(hasta aca no hay problema).

El problema es que la funcion necesita un parametro del formato “DateTime”, y hasta el momento no he podido convertir un String y que la funciona me funciona correctamente.

Tengo el siguiente codigo:

<?php      if(isset($  _POST)){                   $  new_date = $  _POST['today']; // capturo la fecha que viene de un DatePicker           $  fecha = new datetime();          $  fechafinal = $  fecha->createFromFormat('d-m-y', $  new_date);                  // $  specifiedDate = new DateTime('10/09/2019'); este es el codigo original y funciona bien cuando al fecha se escribe manualmente.          $  date = firstDayOf('week', $  fechafinal);         echo $  date->format('l, jS F Y');       } ?> 

PD: este es el primer codigo en PHP y web que realizado, y estoy un poco perdido con el tema de las conversion de formato.