Search By Label
def add_items(n): return n + n + n print add_items(10)
The O(N^2) time complexity means that the running time of an algorithm grows quadratically with the size of the input. It often involves nested loops, where each element in the input is compared with every other element.
def print_items(n): for i in range(n): for j in range(n): print(i,j) print_items(10)
def print_items(n): for i in range(n): for j in range(n): print(i,j) for k in range(n): print(k) print_items(10)
O(n)
for the simple search. It's a guarantee that the simple search will never be slower than O(n) time. In a code where the worst scenario is go thought all the elements the notation is O(n)
def print_items(n): for i in range(n): print(i) print_items(10)
brew install redis
brew services start redis
redis-cli ping
PONG
.// Custom Hook const useProducts = () => { const [products, setProducts] = useState([]); useEffect(() => { fetch("/api/products") .then((res) => res.json()) .then((data) => setProducts(data)); }, []); return products; }; // Container Component function ProductContainer() { const products = useProducts(); return <ProductList products={products} />; } // Presentational Component function ProductList({ products }) { return ( <ul> {products.map((product) => ( <li key={product.id}>{product.name}</li> ))} </ul> ); }
ed25519
algorithm to securely identify yourself:ssh-keygen -t ed25519 -C "brisamedina05@gmail.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
mkdir project-directory cd project-directory
git clone git@github.com:your-organization/your-repository.git
cd your-repository npm install
npm run dev
sudo apt install nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
rm -rf node_modules npm install
npm run dev
orders
with documents representing individual orders. Each document has fields like order_id
, customer_id
, product_name
, and price
. We want to calculate the average order value for each customer.db.orders.aggregate([ { $group: { _id: "$customer_id", total_spent: { $sum: "$price" }, total_orders: { $count: {} } } }, { $project: { average_order_value: { $divide: ["$total_spent", "$total_orders"] } } } ])
customer_id
.$sum
.$count
.total_spent
by total_orders
.customer_id
and the calculated average_order_value
.mongosh "mongodb+srv://{MONGO_COLLECTION_USER}:{MONGO_COLLECTION_PASSWORD}@{MONGO_APP_NAME}.yng1j.mongodb.net/?appName={MONGO_APP_NAME}"
// show databases show dbs // use database use <db_name> // show collections show collections // finally interact with them, for example db.users.findOne()