unitt only 1 number float
using UnityEngine.UI;
public Text textDivision;
public float division = 1.0/3; // this is equal to 0.33333333333333333333333333...
textDivision.text = division.ToString("F1"); //shows only 0.3
unitt only 1 number float
using UnityEngine.UI;
public Text textDivision;
public float division = 1.0/3; // this is equal to 0.33333333333333333333333333...
textDivision.text = division.ToString("F1"); //shows only 0.3
count number of zeros in array in O(logN)
int firstZero(int arr[], int low, int high)
{
if (high >= low)
{
// Check if mid element is first 0
int mid = low + (high - low)/2;
if (( mid == 0 || arr[mid-1] == 1) && arr[mid] == 0)
return mid;
if (arr[mid] == 1) // If mid element is not 0
return firstZero(arr, (mid + 1), high);
else // If mid element is 0, but not first 0
return firstZero(arr, low, (mid -1));
}
return -1;
}
// A wrapper over recursive function firstZero()
int countZeroes(int arr[], int n)
{
// Find index of first zero in given array
int first = firstZero(arr, 0, n-1);
// If 0 is not present at all, return 0
if (first == -1)
return 0;
return (n - first);
}
//Credits : GeeksForGeeks
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us