A wiggle sequence 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, or two non-equal elements, is trivially a wiggle sequence.
For example:
A subsequence is obtained by deleting some elements (possibly zero) from the original sequence, keeping the remaining elements in their original order.
Given an integer array nums, return the length of the longest wiggle subsequence of nums.
1. The approach for this question is to find difference between every consecutive elements of array i.e(nums[i+1]-nums[i] in the code) to check the difference is positive or negative , by doing this also check the pattern of positive-negative or negative-positive , do this by storing every current difference of elements and compare it with previous difference and check the pattern of pos-neg or neg-pos.
2. Count this for how much elements of the given array this pattern is following and simply return the count
There are n cars on an infinitely long road, numbered from 0 to n - 1 from left to right, with each car at a unique position. You are given a 0-indexed string directions of length n, where:
All moving cars travel at the same speed. Collisions are calculated as follows:
Return the total number of collisions that will occur on the road.
1. We need to keep track of previous car direction and if it will collide with current car direction.
2. A special case arises with cars going in left direction, which we track using a separate counter.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?