All Posts

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.

Leetcode 189: Rotate Array

You are given an integer array nums. Your task is to rotate the array to the right by k steps, where k is a non-negative integer.

Leetcode 198: House Robber

You are a burglar planning to rob houses along a street. Each house has an amount of money, but robbing two adjacent houses will trigger an alarm. Given an integer array nums representing the money stashed in each house, find the maximum amount you can rob without triggering the alarm.

Leetcode 200: Number of Islands

You are given a 2D grid representing a map, where ‘1’ represents land and ‘0’ represents water. Your task is to count how many islands are formed by connecting adjacent lands horizontally or vertically. An island is a collection of ‘1’s connected either horizontally or vertically.

Leetcode 209: Minimum Size Subarray Sum

Given an array of positive integers and a target value, find the minimal length of a contiguous subarray whose sum is greater than or equal to the target. If no such subarray exists, return 0.

Leetcode 213: House Robber II

You are tasked with designing a strategy to rob houses along a circular street, where no two adjacent houses can be robbed on the same night. The goal is to maximize the total money stolen without triggering security alarms.