What are Virtual Kubernetes Clusters(VCluster)?

Virtual clusters are fully working Kubernetes clusters that run on top of other Kubernetes clusters. Compared to fully separate “real” clusters, virtual clusters reuse worker nodes and networking of the host cluster. They have their own control plane and schedule all workloads into a single namespace of the host cluster. Like virtual machines, virtual clusters partition a single physical cluster into multiple separate ones.

Read more »

index()

The index() method returns the index of the specified element in the list.

1
2
3
4
5
6
7
8
animals = ['cat', 'dog', 'rabbit', 'horse']

# get the index of 'dog'
index = animals.index('dog')

print(index)

# Output: 1

set()

1
2
3
4
5
6
triplets = set() # automatically remove duplicates
triplets.add((1,2,3))
triplets.add((1,2,4))
triplets.add((1,2,3))
print(triplets)
# output: {(1, 2, 3), (1, 2, 4)}

isalnum()

The isalnum() method returns True if all the characters are alphanumeric, meaning alphabet letter (a-z) and numbers (0-9).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Solution:
def isPalindrome(self, s: str) -> bool:
left, right = 0, len(s) - 1
while left < right:
if not s[left].isalnum():
left += 1
continue
if not s[right].isalnum():
right -= 1
continue

if s[left].lower() != s[right].lower():
return False

left += 1
right -= 1

return True

ord()

ord() function returns the Unicode code from a given character.

Read more »

What is Dynamic Programming?

Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of subproblems, so that we do not have to re-compute them when needed later. This simple optimization reduces time complexities from exponential to polynomial.

Read more »

Moore Voting Algorithm

[Leetcode 169] Majority Element

Given an array nums of size n, return the majority element.

The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.

Read more »

[Leetcode 121] Best Time to Buy and Sell Stock

You are given an array prices where prices[i] is the price of a given stock on the ith day.

You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.

Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.

Read more »

[Leetcode 136] Single Number

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

You must implement a solution with a linear runtime complexity and use only constant extra space.

Read more »

What is a Monotonic Stack

A monotonic stack is a stack whose elements are monotonically increasing or decreasing. It contains all properties that a typical stack has and its elements are monotonic decreasing or increasing.

Monotonic increasing stack: [2 3 5 6 9]
Monotonic decreasing stack: [9 6 5 3 2]

Read more »

Intro

A linked list is a data structure which represents a sequence of nodes. In a singly linked list, each node points to the next node. In a doubly linked list, each node points to both the next and previous node.

Read more »
0%