Monday, 27 October 2025

Black bud Leet code Interview exam

 2 question

1.on cards
2.


https://leetcode.com/discuss/post/537699/google-onsite-card-game-by-sithis-8w7a/

https://leetcode.com/problems/count-array-pairs-divisible-by-k/description/

https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k/description/


Saturday, 25 October 2025

parent to child

 Solution 2: Shared service (recommended for complex applications)

For more complex applications, a shared service with an RxJS Subject or BehaviorSubject is a cleaner solution for decoupled communication. 
1. Create a shared service
The service will hold an observable that other components can subscribe to. 
typescript
// dropdown.service.ts
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class DropdownService {
  private dropdownSubject = new Subject<any>();

  // Observable for other components to subscribe to
  dropdownValue$ = this.dropdownSubject.asObservable();

  // Method to be called by child1 when the dropdown changes
  sendDropdownValue(value: any) {
    this.dropdownSubject.next(value);
  }
}
Use code with caution.
2. Send the value from the first child (app-newhire-header-details)
In newhire-header-details.component.ts, inject the service and call its sendDropdownValue() method.
typescript
import { Component } from '@angular/core';
import { DropdownService } from '../dropdown.service'; // Adjust path

@Component({ ... })
export class NewhireHeaderDetailsComponent {
  constructor(private dropdownService: DropdownService) {}

  onDropdownSelectionChange(value: any) {
    this.dropdownService.sendDropdownValue(value);
  }
}
Use code with caution.
3. Subscribe to the event in the second child (app-personal-tab)
In personal-tab.component.ts, inject the service and subscribe to the observable to get the latest value.
typescript
import { Component, OnInit, OnDestroy } from '@angular/core';
import { DropdownService } from '../dropdown.service'; // Adjust path
import { Subscription } from 'rxjs';
import { YourApiService } from './your-api.service'; // Assume you have an API service

@Component({ ... })
export class PersonalTabComponent implements OnInit, OnDestroy {
  private dropdownSubscription: Subscription;

  constructor(private dropdownService: DropdownService, private yourApiService: YourApiService) {}

  ngOnInit() {
    this.dropdownSubscription = this.dropdownService.dropdownValue$.subscribe(selectedValue => {
      if (selectedValue) {
        this.callApi(selectedValue);
      }
    });
  }

  callApi(value: any) {
    this.yourApiService.getData(value).subscribe(
      (response) => console.log('API response for PersonalTab:', response),
      (error) => console.error('API error:', error)
    );
  }

  ngOnDestroy() {
    // Unsubscribe to prevent memory leaks
    if (this.dropdownSubscription) {
      this.dropdownSubscription.unsubscribe();
    }
  }
}
Use code with caution.

Parent to child

 both this child calles in the parent i have challange that in child1 dropdown selection change i need to call api in child2 how to do it <app-newhire-header-details [parentData]="parentData" [formData]="combinedFormData.masterHeader" (formDataChange)="onFormDataReceived('masterHeader', $event)"></app-newhire-header-details> <app-personal-tab [formFields]="tabFormFields[2]" [tabKey]="2" [formData]="combinedFormData.personal" (formDataChange)="onFormDataReceived('personal', $event)" (nextTab)="nextTab()" (prevTab)="prevTab()"> </app-personal-tab>

For child-to-child communication, where a change in one child component triggers an action (like an API call) in a sibling child component, the standard Angular approach is for the parent component to act as a mediator
. A shared service is a more robust solution for complex scenarios or when components are not direct siblings. 
Solution 1: Parent as a mediator
This is the most straightforward and recommended approach for components that are direct siblings under the same parent.
1. Emit an event from the first child (app-newhire-header-details)
In newhire-header-details.component.ts, emit an event when the dropdown selection changes. 
typescript
import { Component, Output, EventEmitter } from '@angular/core';

@Component({ ... })
export class NewhireHeaderDetailsComponent {
  // Add a new @Output for the dropdown change
  @Output() dropdownChange = new EventEmitter<any>();

  onDropdownSelectionChange(value: any) {
    // This method is called by the dropdown's (change) or (selectionChange) event
    this.dropdownChange.emit(value);
  }
}
Use code with caution.
2. Listen to the event in the parent component
The parent component listens for the event from the first child. 
typescript
// parent.component.html
<app-newhire-header-details
  [parentData]="parentData"
  [formData]="combinedFormData.masterHeader"
  (formDataChange)="onFormDataReceived('masterHeader', $event)"
  (dropdownChange)="onHeaderDropdownChange($event)">  <!-- Listen for the dropdownChange event -->
</app-newhire-header-details>

<app-personal-tab
  [formFields]="tabFormFields[2]"
  [tabKey]="2"
  [formData]="combinedFormData.personal"
  [headerDropdownValue]="headerDropdownValue"  <!-- Pass the value to the second child -->
  (formDataChange)="onFormDataReceived('personal', $event)"
  (nextTab)="nextTab()"
  (prevTab)="prevTab()">
</app-personal-tab>
Use code with caution.
In parent.component.ts, implement the event handler and use it to update an input property on the second child.
typescript
// parent.component.ts
import { Component } from '@angular/core';

@Component({ ... })
export class ParentComponent {
  headerDropdownValue: any;

  onHeaderDropdownChange(selectedValue: any) {
    // Save the new value from the first child
    this.headerDropdownValue = selectedValue;
    // The second child will be notified of the change via its @Input()
  }

  // ... other methods
}
Use code with caution.
3. Watch for changes in the second child (app-personal-tab)
The second child needs to receive the value from the parent and take action when it changes.
typescript
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { YourApiService } from './your-api.service'; // Assume you have an API service

@Component({ ... })
export class PersonalTabComponent implements OnChanges {
  // @Input to receive the value from the parent
  @Input() headerDropdownValue: any;

  constructor(private yourApiService: YourApiService) {}

  ngOnChanges(changes: SimpleChanges) {
    if (changes['headerDropdownValue']) {
      const selectedValue = changes['headerDropdownValue'].currentValue;
      if (selectedValue) {
        // Call your API based on the selected value
        this.callApi(selectedValue);
      }
    }
  }

  callApi(value: any) {
    // Logic to call your API based on the value
    this.yourApiService.getData(value).subscribe(
      (response) => console.log('API response for PersonalTab:', response),
      (error) => console.error('API error:', error)
    );
  }
}
Use code with caution.


Friday, 17 October 2025

Forked join exampl

 Used fork join to call dropdown list

loadDropdownData() {
  forkJoin({
    countries: this.masterservice.GetCountries(),
    divisions: this.masterservice.GetDivisions(),
    locations: this.masterservice.GetLocations()
  }).subscribe({
    next: (res:any) => {
      this.countries = res.countries;
      this.divisions = res.divisions;
      this.locations = res.locations;
      console.log(res);
    },
    error: (err) => {
      console.error('Error loading dropdown data', err);
    }
  });
}

Amiercion ailines interview questions

 1.application monitoring for micrioservices

2.multiple jwt token handling in the api

3.toggle handle in react

4.global error handle in angular

5.charts in react

6.design of ecomerce app using microservices securly

7.build pipeline for microservices.

8.Write a JavaScript function asyncMap(arr, asyncFn) that takes an array and an asynchronous function,

 applies asyncFn to each item in parallel, and returns a Promise that resolves with an array of results in the original order. 

Handle errors so that if any asyncFn fails, asyncMap rejects with that error

9.Write a function that takes an array of integers and returns the length of the longest subarray with consecutive elements (regardless of order). 

For example, [2, 6, 1, 9, 4, 5, 3] should return 6 (for subarray [2, 1, 4, 5, 3, 6]).

10.Given a products table and a sales table, write an SQL query to find products that have never been sold but are still in stock.

Thursday, 16 October 2025

Scoped vs transient vs singleton

 

Transient: every time new object instance created

scoped: once you refresh the service new instance created

singleton: once you restart the application then only new instance created.



Friday, 10 October 2025

Devops

 https://paperlive.in/blog/over-60+-azure-devops-interview-questions-and-answers-to-prepare-for-2025


junior devops engnr

  Position Overview: We are a growing start up seeking a Junior Azure DevOps Engineer with 2 to 3 years of experience to support our Azure...