Given an array arr[] of N integers. Perform the following steps n-1 times

For every kth operation:
On the right, rotate the array clockwise by 1.
Delete the (n-k + 1) last element.


A = {1, 2, 3, 4, 5, 6}. Turn the array clockwise, d. H. After the rotation, the array A = {6, 1, 2, 3, 4, 5} and delete the last element, which is {5}, so A = {6, 1, 2, 3, 4} , Rotate the array a second time and delete the penultimate element with the value {2}, so that A = {4, 6, 1, 3}. Follow these steps when the fourth time is reached and the fourth to last element is missing 1. Element, ie {1}, so A = {3, 6}. If you continue this procedure, the last element in A is {3}, so outputp is 3

How can one solve it?

mysql – PHP – Pass an array through a dynamic checkbox value

I'm trying to pass 4 variables through a check box, which I think is to make an arrangement and then hand over the variables I need. So what I have is a dynamic check box that works properly right now when I pick it up in the other PHP version, I get it with unserialize, but it does not show me anything, I do not know if I'm doing something wrong

I show you my code:

fetch_assoc()) { $array = ( 'id_s' => $_SESSION('idusr'), 'ti_s' => $_SESSION('tipo'), 'id_r' => $_SESSION('rediccionaridPerfilInm'), 'ti_r' => $_SESSION('rediccionartipoPerfilInm') ); if($fila3('us_tipo')==1) // Usuario normal { ?>

and in the other file I get it like this:

 $miArray = unserialize($_POST("checkbox"));
 echo $miArray;

Finally I want to get these 4 variables and save them in the database.

Algorithms – Space-saving storage of a trie as an array of integers

I'm trying to efficiently store a list of strings in an array with the following restrictions:

  • All strings consist of 8-bit characters (0..255).
  • The last attempt is static, d. H., Once created, no strings need to be inserted or removed.
  • Look up a bunch of length $ m $ must be done in $ O (m) $ with a constant factor as low as possible.
  • The only available memory structure for storing the data is an array of integers. In particular, there are no pointers or dynamic memory allocation.
  • Once an array has been allocated, its size can not be changed and its memory can no longer be freed.
  • Memory is rare, so the final data structure should be as compact as possible and no unnecessarily long arrays should be allocated.
  • Calculation time is not important for the build phase, but memory usage is subject to the above terms.


My current approach is an experiment stored in the array with the following structure:

fbox {$ vphantom {^ M_M} ; i_0 ; ldots ; i_ {255} ; $} ,
fbox {$ vphantom {^ M_M} ; i ^ * _ 0 ; ldots ; i ^ * _ {255} ; $} ,
fbox {$ vphantom {^ M_M} ; w ; $} ,
fbox {$ vphantom {^ M_M} ; mathit {last} ; $} ,
fbox {$ vphantom {^ M_M} ; B_0 ; $} , fbox {$ vphantom {^ M_M} ; B_1 ; $} , ldots

Where $ i_k $ is an association of each unique input character $ k $ to a whole number $ 1 leq i_k (c) leq w $ With $ i ^ * $ is the corresponding reverse figure of $ i $, Each node in the trie is stored as a block $ B $ the size $ w + 1 $, The assignment $ i $ It is used to reduce the size of each block because it does not need to store the entire range of characters, just the number of characters actually used. This is at the expense of another indirection when looking up words. (The field $ mathit {last} $ This is used as a pointer to the field after the last block in the array to find the next mapping point.)

Each block looks like this:

fbox {$ vphantom {^ M_M} ; b ; $} ,
fbox {$ vphantom {^ M_M} ; c_1 ; ldots ; c_w ; $}

$ b $ is either 1 if the word represented by this block is trie, and 0 if not. $ c_i $ represent all unique input characters (after the $ i $ Mapping). If the value of $ c_i $ is equal to 0, there is no entry for this character. Otherwise $ c_i $ is the index in the array where the block starts with the following letter.

To create the trie, the bijection is calculated first $ i $/$ i ^ * $ and $ w $, Then new blocks are added with each prefix not already in the trie.


While this approach works so far, my main problem is memory usage. The current approach is extremely memory-intensive if only a few words have longer prefixes (which is usually the case). Some tests show that the typical number of non-empty fields is only about 2-3% of the total array. Another problem is that the final number of array fields needed will not be available until after the experiment has already been created; H. I have to be conservative when allocating memory to avoid losing memory when adding new blocks.

My idea was to use a compressed trie / radix trie with two types of blocks instead: 1) the ones above that represent nodes with multiple child blocks, and 2) compressed blocks (similar to C char arrays), the suffixes in the trie pose. For example, if the words apple juice and apple tree Should be stored in the tree, there would be seven normal blocks for the common prefix apple and one compressed block each juice and tree, (You may also be able to use them to combine common suffixes for words with different prefixes.)

The problem with this is that there may be gaps in the array when creating the experiment. Consider the situation in the above example, in the only apply juice is stored as a compressed block in the trie. Now apple tree is inserted, which would lead to a removal of the apple juice Block and add juice and tree instead blocks that generally do not fit in the left hole.

Under the given conditions, can anyone see an algorithm to store strings most efficiently in the array while maintaining the linear lookup time?

Javascript – Why can not I save multiple .value in the array?

//Variaveis Globais
var d = document;
var Nomes = ();

function processar(idTabela) //Inserir Linhas e Verificar se ja foi escrito o nome
	var newRow = d.createElement('tr');
	newRow.insertCell(0).innerHTML = d.getElementsByName('Nome')(0).value;
    newRow.insertCell(1).innerHTML = d.getElementsByName('Idade')(0).value;
    Nomes.push = d.getElementsByName('Nome')(0).value;

    return false;


        First name:  


Add value to an array in C

I'm trying to add an event to the event registration screen, and I'm not getting it. When I switch to the list screen, the events are not displayed.

I declare the global array outside of main (). Can someone help me?

I do the work of this semester in C, which the teacher has requested.


int opcao_menu;

int evento_id(24);
char evento_titulo(24), evento_horario(24), evento_lugares(24);

int main(int argc, char *argv()) {
	return 0;

int menu() {
	printf("-- MENU --n");
	printf("1 - Cadastrar peça teatral de hojen");
	printf("2 - Vender ingresson");
	printf("3 - Fechamento do caixa de hojen");
	printf("4 - Sair do sisteman");
	printf("Digite a opção: ");
	scanf("%d", &opcao_menu);
	return 0;

int telaMenu() {
		case 1:
		case 2:
		case 3:
		case 4:
	opcao_menu = 0;
	return 0;

int telaCadPeca() {
	int i, id, lugares, qtd_evt, chave_evt;
	char titulo, horario, finalizar;

	printf("Nome da peça (Não utilizar acentuação): ");
	scanf("%s", &titulo);
	printf("Horário (Formato: 99:99): ");
	scanf("%s", &horario);
	printf("Quantidade de lugares: ");
	scanf("%d", &lugares);
	//qtd_evt = sizeof(evento_id)/sizeof(int);	
	//chave_evt = qtd_evt;
	for( i=0; i<24; i++ ){
		if(!evento_titulo(i)) {
			chave_evt = i;
	//evento_id() = chave_evt;
	evento_titulo(chave_evt) = titulo;
	evento_horario(chave_evt) = horario;
	evento_lugares(chave_evt) = lugares;
	printf("Evento cadastrado com sucesso! %d - %s às %s", chave_evt, titulo, horario);
	return 0;

int telaVendaIngresso(){
	int i, qtd_evt; 
	int id_evento, cod_evento;
	char titulo;
	printf("O ingresso é para qual evento? Escolha um código abaixo:n");
	for( i=0; i<24; i++ ){
		id_evento = evento_id(i);
		if( id_evento > 0 ) {
			printf("%d - %sn", id_evento, evento_titulo(i));
	printf("Digite o código do evento: ");
	scanf("%d", &cod_evento);
	return 0;

int telaFechamentoCaixa(){
	return 0;

int telaSair(){
	printf("Sistema fechadon");
	return 0;

Array – Javascript Map / Filter / Shrink Via Facebook Messenger Data

I analyzed some messenger group data from JSON. I'm trying to get some statistics from it.

Do I miss something obvious about that map / filter / reduce Powers through a large for loop of filters? Would this code be checked for an internal analysis tool?

people.forEach(function (person) {
    let obj = {}; = person;
    obj.messageCount = messages.filter((obj) => obj.sender_name === person).length;

    obj.photoMessageCount = messages.filter((obj) => ((obj.sender_name === person) && (( != null) )).length;

    obj.videoGifMessageCount = messages.filter((obj) => ((obj.sender_name === person) && ((obj.gifs !=null) || (obj.videos!= null))).length;

    obj.audioMessageCount = messages.filter((obj) => ((obj.sender_name === person) && (obj.audio_files != null))).length;

    obj.a = obj.photoMessageCount + obj.videoGifMessageCount + obj.audioMessageCount;


Python function with array arguments in Sympy

I would like to write a function in sympy that uses two symbolic vectors as arguments and returns their inner product, eg.

import sympy as sy
phi = sy.symbols("phi")

How do I declare a function:

fun= sy.Function("fun")

of two arguments like v1,v2 that gives back her inner product