Search Results


29 matches found for 'exists'

Forall and Exists in Scala

... the set satisfy the predicate, forall returns true. In set theory, the inverse of forall is the exists function, where if any value satisfies the predicate, exists returns true.


Bloom Filter

A set data structure uses a hashing function to store values and to verify if a value exists. Bloom filters are similar in that it uses multiple hashing functions to store values and to verify if a value exists.


Javascript Essentials

... object and returns it. The 'in' keyword The in keyword allows you to check if a property exists in an object. "a" in {"a": "b"} => true // "a" is a property (or key) of the object "c" in {"a": "b"} => false // "c" is not a property (or key) of the object WARNING: Unlike Python's in keyword, in Javascript this can work against you.


Overlapping linked lists

... with it, then we know there is an overlap. Solution def does_overlap(ll_a, ll_b): exists = collections.defaultdict(bool) while ll_a: exists[ll_a] = True # assumes that linked list nodes can be represented uniquely as a key string ll_a = ll_a.


A quick look at Scala and the syntax

The syntax in Scala can look confusing very fast.. def exists(s: Set, p: Int => Boolean): Boolean = !forall(s, (x: Int) => !p(x)) p here is a function parameter; okay, I get that.


Search in a rotated sorted array

... found in the array return its index, otherwise return \(-1\). Note: You may assume no duplicate exists in the array. Note: Your algorithm's runtime complexity must be in the order of \(O(log n)\).


Detecting a cycle in a linked list

... loop above may look scary, but at this point we have already confirmed that a linked list cycle exists. Putting everything together, we have: def has_cycle(head): slow = fast = head while slow and slow.


B-Trees vs. LSM Trees

B-Trees Modern databases are typically represented as B-Trees or LSM Trees (Log structured merge trees). B-trees are "tried and true" data structures that are popular in database usage, most notably SQL databases.


Find the duplicate number

... values of the array as pointers, then running into the same pointer value implies that a cycle exists. Solution def findDuplicate(self, nums): """ :type


Build a Trie in Python

... a new Trie for that character and place it in the current trie's array. If this character already exists in the array, we should keep that trie, and re-use it, rather than replace it.


Design Concepts

In this article, I want to go over some fundamental design concepts that are useful for coming up with system design. Requirements Functional Requirements Describes specific behaviors i.e. If a URL is generated, it is composed of a Base64 encoded alias Non-functional Requirements Describes architectural requirements i.


Git the Essentials

... repository (origin, in this case). Pulling Scenario: I am currently on branch G, which exists in my remote repository called origin. Susan just pushed her latest changes to branch G in origin.


Storing passwords into a database

... already had a list of hashed passwords for the most commonly used passwords? (Hint: it's already exists somewhere on the web) Another key thing is that your typical hash (MD5, SHA-256) is incredibly fast to execute, because their purpose is to verify file hash checksum integrities.


Atomic operations with Elasticsearch

Preface Elasticsearch is a distributed, open source search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured. Key Terms: Document - Serialized JSON data.


Virtual Memory

... problematic than paging In a nutshell, Virtual Memory allows for more space than there actually exists in actual memory by using swap files. Nowadays it wouldn't be surprising to see swap files as large as 1 GB.


Data stores in Software Architectures

Use Cases There are many ways to store your data. In this article we'll walk through some examples of data storage in common system designs. Reminder: There is no single best storage choice and they may vary heavily depending on things such as access patterns and scale.


OS 101

... It describes a data resource, and how that resource may be accessed. For every open file, there exists a file descriptor, so if you have 100 files open, then you have 100 file descriptors.


Distributed scaling with Relational Databases

... consistently write to or read from a valid partition, and ensure that some type of failover exists if a partition is dead. I won't get too deep into the details for these techniques here, but their information is widely available on the web.


Perfect Squares

Problem Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Examples: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4.


Local Secondary Index vs. Global Secondary Index

... ID. Each partition would now have its own secondary index that is mapped to a document ID that exists in the same partition's primary index. The Document IDs that each secondary index points to are localized in its own partition The upside of this approach is that whenever you need to update a specific document by its document ID, you only need to update one of these partitions.


Square each element of a Scala list

... 2: Mapping def squareList(xs: List[Int]): List[Int] = xs map (x => x * x) In Lists, there exists a method called map which happens to be a very handy method. This is a very simple and straightforward 1-line function that is much more readable than Method 1.


Counting the path of sums

Description Given a binary tree with nodes containing integer values (positive or negative), how can you count up all the paths that equal to some target sum? Note, that the paths do not have to start from the root; it may start from any sub-tree and end at another sub-tree, as long as the path goes down the tree.


Add SSL certificates to a website

... giver do in a nutshell? The certificate provider verifies that the HTTPS server legitimately exists on that domain Is SSL encryption using public key cryptography or private key cryptography? Actually, it uses both.


Spring - Injecting more than one bean of the same type

Problem By default, Spring will autowire beans by type. When a bean is created that depends on other beans, it will check for the existence of the required dependencies by types. Creating another bean of the same type will result in a very common exception: NoUniqueBeanDefinitionException.


Next Permutation

Problem Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).


Machine Learning Basics

... functions: tan ReLU sigmoid Cost Function In neural networks, the concept of loss still exists, except that calculating the loss can be a bit more trickier when we have to apply back-propagation with a densely connected network.


Forward Proxy and Reverse Proxy

Proxies have a wide variety of use cases with great benefits. In this article, I go over two variations of proxies. Forward Proxy One day, in a school classroom setting, a teacher wants an anonymous survey filled out by all of the students in the classroom.


Find a path in a maze from start to finish

... a maze, a start point, and an end point, find a path from the start point to the end point if it exists. Input maze: 2D boolean array of size greater than 1 x 1, where False represents a wall (not traversable) and True represents an empty space (traversable) start: an object with x, y coordinates end: an object with x, y coordinates Approach The key to solving this problem is DFS.


DNS

DNS (Domain name system) is essentially a phonebook for internet addresses on the Internet. Every URL with alphanumeric characters are mapped to IP addresses, either IPv4 or IPv6. That means https://google.