Monday, 4 October 2021

Move Zeros

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0]. Note: You must do this in-place without making a copy of the array. Minimize the total number of operations. ...
Share:

Sunday, 12 September 2021

Find Peak Element

A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine that num[-1] = num[n] = -∞. For example, in array [1, 2, 3, 1], 3 is a peak element and your function should...
Share:

Tuesday, 7 September 2021

Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 bool isPalindrome(char* s) { int i, j, len; len = strlen(s); i = 0; j = len - 1; while(i...
Share:

Sunday, 1 August 2021

Balanced Binary Tree

Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 /** * Definition for a binary tree node. * struct...
Share:

Thursday, 29 July 2021

Leaders in an array

An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include <iostream> using namespace std; int main(){ int arr[] = {18, 16, 17, 4, 3, 5, 2}; int n = sizeof(arr)/sizeof(arr[0]); ...
Share:

Sunday, 7 February 2021

Getting rollout status of Kubernetes Deployment object

With kubectl rollout status deployment deployment-name, you can check the rollout status of a Kubernetes Deployment deployment-name. If the rollout completes successfully, kubectl rollout status returns a zero exit code otherwise a non-zero exit code is returned. Assuming, we have a Deployment name app with three replicas and we updated the Deployment with a new image. Running the kubectl rollout...
Share:

Contact Me

Name

Email *

Message *

Popular Posts