Search Results

28 matches found for 'string'

Phone Number Mnemonics in Python

Recursion is a great way to come up with permutations of strings or elements. Not necessarily because of the performance (iterative styles are usually faster) but because of simplicity and organization - like many algorithms with functional programming languages like Scala, recursive functions in general look neater, nicer, and easier to categorize.

String Manipulation in Python 3+

There are a few ways to search for a string in Python (3+): String operations str.find(sub[, start[, end]])] "shadow walker".find('w') => 5 This gives you the index of the first match.

Python String Tricks - Performance considerations

If a string is changed to become bigger, consider trying to find the maximum size of the final string early on in a quick pass (strive for \(O(n)\)) Consider working from the tail of the string and iterating backwards if, say, 1 character needs to be replaced with 2.

Misconceptions of ASCII and Unicode

... this can result in a large overhead in terms of memory space usage. For this reason, if most strings use ASCII characters, it will be much more space-efficient to use UTF-8. On the flip side, many higher-order characters can take a whopping 3 bytes in UTF-8, while they fit in just 2 bytes in UTF-16.

Escape from the Strings

... value between two other values. In some programming languages or templating languages, string interpolation is a feature that is quite similar to string escaping, in that it allows you to escape variables vs.

Reversing words in a string : the double reverse

Problem Reverse all words (separated by space) in a string Input \(s\) - a string Approach Nice case and point for really examining the examples.

Replace all occurrences of a space inside an array

Problem Given an array of characters, replace all occurrences of a space with another string. Assume that the array has enough space to contain all of the replacements. Input A - An array of characters which may or may not have spaces word - The string to replace spaces with.

Algorithm Handbook

... b, ab\) (4) \(a, b, c => \theta, a, b, ab, c, ac, bc, abc\) (8) \(O(n!)\) Factorial run time (ex: string permutations) Example: \(a => a\) (1) \(ab => ab, ba\) (2) \(abc => abc, acb, bac, bca, cab, cba\) (6) Bit Operations Sequence of 1's to the right of position \( i \) \( 0000\)\(0000\) => \( 0000\)\(1111\), \(i = 5\) Shift 1 to the left by \(i\) times.

A primer on MapReduce

... in some container and transform them. For example, if I want to convert a list of numbers to strings in Javascript: [0, 1, 2, 3].map(number => Integer.parseInt(number)); Reduce Reduce is also known as folding or aggregation.

How to convert a PPM image to grayscale in C++

... void grayscale(); // feel free to add more if you want! private: string magicNumber; // A "magic number" for identifying the file type int width; // Width of the image int height; // Height of the image int maxColorVal; // Maximum color value char *threeChan; // A series of rows and columns (raster) that stores important binary image data }; string magicNumber - For simplicity of this guide, we'll let this be "P6".

Comparison Charts of File Storage Formats

... Comma Separated ValuesTab Separated ValuesPipe Separated Values Cannot distinguish between string types and number typesAmbiguity with parsing delimited values and newlines across implementationsAmbiguity with column headers that might or might not be present Some formats are unescaped, causing additional complications when rows have embedded values such as double-quotes.

Longest Substring Without Repeating Characters

Problem Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.

Data stores in Software Architectures

... used for geospatial operations, where two-dimensional coordinates are taken as input and a Base32 string encoding is returned as output. There are many libraries out there for geohashing, and Postgres also has the PostGIS plugin, which allows you to calculate geohashes from coordinates in the query body.

Decode number of ways

... 06) is invalid because "06" cannot be mapped into 'F' since "6" is different from "06". Given a string s containing only digits, return the number of ways to decode it. The answer is guaranteed to fit in a 32-bit integer.

B-Trees vs. LSM Trees

... inside an append-only log file (that is on disk, not in-memory), which contains the actual value string. For example, suppose you have a db1.txt log file with key/value pairs, and you have the key foo set to bar.

Java Essentials

JVM Java is a statically typed language that is compiled into bytecode (i.e. with javac) and understood only by the JVM, or Java Virtual Machine. The JVM is an interpreter that reads the Java bytecode and translates them into machine code before execution.

Python Essentials

... pickling is very similar to the json module, which allows you to serialize Python objects into strings and deserialize strings back to Python objects. Few use cases for pickling: You want to convert executable logic in Python into a byte stream and vice-versa.

2023's EOY Tech Buzz Words

... is a popular word most commonly used in programming idioms like "string interpolation". To inter-polate, is to insert something into or in between. Example sentences: "Dynamic numbers are interpolated into this string via code.

Web Development 101

... the user's privileges, groups, and other characteristics. A JWT is represented as one large string composed of base64Url encoded values. The header, the payload, and the signature are all base64Url encoded separately, and concatenated all into one string.

Unique Permutations

... is to convert the list objects into immutable tuple objects. An alternative solution is a string, but converting a list to a string will involve a .copy() operation which takes \(O(n)\) time, so this isn't the best choice.

Useful Links

... Encrypting, Hashing Python Awesome Python CPython Time Complexity PyPy vs CPython strings and bytesarray (Python 3+) Performance Tips Javascript, ES6 ES6 Destructuring Classes suck in Javascript React Hooking up React Redux with Django Backend Import issues with IntelliJ / WebStorm jQuery jQuery Cheat Sheet Chaining vs.

Build a Trie in Python

... tree data structure used to store a dynamic set or associative array where the keys are usually strings. Build a trie. Input A class Trie, with an empty constructor and three empty methods insert(word) search(word) startsWith(prefix): Assume that all word inputs are lowercase alphabets Approach The key to building a trie is to define a class that has a container which can house up to 26 keys (1 for each lowercase alphabet).

Overlapping linked lists

... exists[ll_a] = True # assumes that linked list nodes can be represented uniquely as a key string ll_a = while ll_b: if exists[ll_b]: return True ll_b = ll_b.

Javascript Essentials

... It just does so much more swiftly than traditional compiled languages.) Lexing is the parsing of strings, splitting them into tokens with semantic meaning (to the compiler/interpreter).

Algorithm Interview Problems

... contains solutions to common interview problems that may be encountered. Arrays Longest Substring Without Repeating Characters Rotate a 2D Matrix Buy/Sell Two Stocks Merge Intervals Next Permutation Random Permutation Replace all occurrences of a space with a string Linked Lists Reversing sublists of singly linked lists Cycles in singly linked lists Overlapping singly linked lists Merging two sorted singly linked lists Merge k sorted lists Recursion Counting the path of sums Money Denominations Phone Number Mnemonics Unique Permutation Dynamic Programming Perfect Squares Find the Maximum Min Path Binary Trees Tree Symmetry Iterative In-Order Traversal of a Binary Tree Construct a Binary Tree from Pre-Order Traversal and In-Order Traversal BST Validate a BST Binary Heaps Merge k sorted lists Graphs Find a path in a maze from start to finish Flip colors in a matrix Search Search in a rotated sorted array Find the Duplicate Number Greedy Algorithms Queue Reconstruction By Height Trie Build a Trie in Python Invariant Compute the max.

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.

Add SSL certificates to a website

... as passwords, or credit card information, since they will appear as garbled and unintelligible strings in the eyes of snoopers. It offers basic protection against man in the middle attacks.

Scanning for memory addresses with Cheat Engine and ZSNES

... Type to Float/Double. Unfortunately, filtering memory addresses by values such as bytes, floats, strings, etc. can be a bit complicated. At this step, you are practically trying to reverse engineer the game; you are thinking about how and where the data is stored by the game programmer(s).