All Posts

Leetcode 324: Wiggle Sort II

You are given an array of integers. Your task is to reorder the array such that the elements alternate between smaller and larger numbers. The sequence should follow the pattern nums[0] < nums[1] > nums[2] < nums[3] > nums[4]….

Leetcode 347: Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements from the array. The answer may be returned in any order.

Leetcode 349: Intersection of Two Arrays

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique, and you may return the result in any order.

Leetcode 368: Largest Divisible Subset

You are given a set of distinct positive integers. Return the largest subset where every pair of elements in the subset satisfies either ‘one element is divisible by the other’.

Leetcode 373: Find K Pairs with Smallest Sums

Given two sorted integer arrays nums1 and nums2 and an integer k, return the k pairs with the smallest sums. Each pair consists of one element from nums1 and one element from nums2.

Leetcode 376: Wiggle Subsequence

A wiggle subsequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. Given an integer array nums, return the length of the longest wiggle subsequence of nums.