-
LeetCode: 198 House Robber
•
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, and the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected, and it will automatically contact the police if two adjacent…
-
LeetCode: 146 LRU Cache
•
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) initializes the LRU cache with positive size capacity. int get(int key) returns the value of the key if the key exists in the cache, otherwise returns -1. void put(int…
-
LeetCode: 509 Fibonacci Number
•
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is: F(0) = 0, F(1) = 1 F(n) = F(n – 1) + F(n – 2), for n >…
-
LeetCode: 408 Valid Word Abbreviation
•
Given a non-empty string word and an abbreviation abbr, return whether the string matches the given abbreviation. A string abbr is a valid abbreviation of word if: It can contain numbers representing how many characters to skip. The numbers should not contain leading zeros. Example: Input: word = "internationalization", abbr…
-
LeetCode: 70 Climbing Stairs
•
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the…
-
Algorithms 101: Deep Dive into the Fibonacci Sequence
•
Deep Dive into the Fibonacci Sequence Introduction The Fibonacci sequence is one of the most famous mathematical sequences, often used in algorithms, data structures, and problem-solving. It starts with 0 and 1, and each subsequent number is the sum of the two preceding numbers. Fibonacci numbers have various applications in…
-
Python 101: Understanding SOLID Principles in Python
•
Understanding SOLID Principles in Python 理解 SOLID 原则 Introduction SOLID is an acronym that represents five fundamental principles of object-oriented programming (OOP). These principles were introduced by Robert C. Martin and are widely used to design software that is scalable, maintainable, and easier to understand. The SOLID principles help developers…
-
Python 101: Command Query Separation (CQS)
•
Command Query Separation (CQS): A Deep Dive for Developers 命令查询分离 (CQS):开发者深入探讨 Introduction Command Query Separation (CQS) is a vital design principle in software development, particularly in object-oriented programming. It was introduced by Bertrand Meyer and promotes a clear separation between methods that alter an object’s state and those that simply…
-
JavaScript 101: Mastering JavaScript Data Grouping with `groupBy`: A Deep Dive
•
Mastering JavaScript Data Grouping with groupBy: A Deep Dive Grouping data is a common task in many programming scenarios, especially when handling large datasets. Whether you’re organizing products by category, people by age, or events by date, the ability to efficiently group data can make your code cleaner and more…
-
50 JavaScript interview questions with answers
•
Here are 50 JavaScript interview questions with answers 1. What is the difference between var, let, and const in JavaScript? English: var has function scope and is hoisted, meaning it can be used before its declaration but can lead to bugs. let and const have block scope. let allows reassignment,…