Tag: code interview

  • LeetCode: 242. Valid Anagram

    Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example: Input: s = "anagram", t = "nagaram" Output: true Input: s = "rat", t = "car" Output: false 问题 给定两个字符串 s 和 t,如果 t 是 s 的字母异位词,则返回 true,否则返回 false。 解决方案 1…

  • LeetCode: 104 Maximum Depth of Binary Tree

    Problem Statement Given the root of a binary tree, return its maximum depth. A binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example: Input: root = [3,9,20,null,null,15,7] Output: 3 问题 给定一个二叉树的根节点,返回其最大深度。 二叉树的最大深度是从根节点到最远叶节点的最长路径上的节点数量。 示例: 输入: root…

  • Code Interview: Python for Coding Interviews

    Python for Coding Interviews Variables Python is dynamically typed, meaning you don’t need to declare the type of a variable. Here’s how it works: n = 0 print(n) # Output: 0 n = "ABC" print(n) # Output: ABC Multiple Assignments You can assign multiple variables in one line: a, b…

  • Code Interview: Data Structures for Coding Interviews

    Data Structures for Coding Interviews Basic Data Structures Arrays Lists Tuples String Manipulation Strings String Methods Sets and Dictionaries Sets Dictionaries Linked Lists Singly Linked List Doubly Linked List Circular Linked List Stacks and Queues Stacks Queues Deques Trees Binary Trees Binary Search Trees AVL Trees Red-Black Trees N-ary Trees…

  • LeetCode: 124 Binary Tree Maximum Path Sum

    Problem Statement Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need…

  • Code Interview: Understanding Shallow Copy vs Deep Copy in Programming

    Code Interview: Understanding Shallow Copy vs Deep Copy in Programming

    Shallow Copy A shallow copy creates a new object, but inserts references into it to the objects found in the original. Changes made to a shallow copy of an object can reflect in the original object if the changes are made to a mutable object contained within the shallow copy.…